UILocalNotification actions and snoozing - iphone

I'm working on a custom app for a client and am still relatively new to iOS development. The app involves setting reminders and I'm using UILocalNotifications. Now from my research the action on the notification will always run the app but I'm really hoping someone can correct me on that. Also from what I've read you are limited to the 'View' or 'Close' options. Ideally I'd love to have 3 buttons on the notification and not have to open the app to perform an action.
I'd like a 'dismiss' option, 'snooze' option, and an 'ok' option that dismisses the notification but runs some code in the background.
I came across a notification related question where somebody suggested opening the app with a modal view and presenting the options from there. Possible, just not as clean, I guess.
Any other ideas or is this what I have to do to achieve my desired functionality? If that's the case is there a way to close the app after I've selected one of my options from the modal view?
Thanks in advance.

That is not possible, as the notification is not created by your app but by the system, so you can't customize the appearance of the notification. (also in iOS 5, the user can choose to display the notifications as banners instead of alerts, which would hide any other button than the view and close button, if that were to be possible).
Secondly there is no way to close your app, as iOS is a user centric system, where the user takes the decision on whether to open or close app, and not the app itself.

Related

How to close System dialogs that appears on app crash?

I'm using xcuitest framework to automate mac application. I get system dialogs when the app is opened again after it crashes. I want to handle the dialog programmatically. But the dialog appears under the process `UserNotificationCenter' instead of the application under test. How can I handle the alert in such case?
You have two options:
Use InterruptionMonitor (documentation, use-case). This
approach is however kinda old and I found, that it does not work for
all dialogs and situations.
Create a method, which will wait for some regular app's button. If the app's button (or tab bar or other such XCUIElement) is visible and hittable after your app started, you can proceed with your test and if it's not, you can wait for the UserNotificationCenter dialog's button and identify&tap it by its string/position.
I'm using the second approach and its working much better, than the InterruptionMonitor. But it really depends on your app layout and use-case.
You should be able to revent it from appearing in the first place. Something like:
defaults write com.apple.CrashReporter DialogType none

Is it possible to write a custom TouchBar app for an existing application?

I have tried looking for an answer to this but can't seem to see anything about it.
I have a piece of software on my laptop (not written by me), that I want to customise. Some of the tasks I do are very repetitive, and could be simplified by just pressing a button on the Touch Bar that executes a number of commands.
Is it possible to write a Touch Bar app that either:
1) Customises the application's original TouchBar app (for which there is none)
2) Runs only when that application is running, and hides when the application is out of focus
Thanks
I believe BetterTouchTool can do that.
Also in the "App Specific" button you can customise when to hide system touch bar and when to show it again

what happens to uialertview when app goes into bkgr

in my app I need to create a bunch of UIAlertView popups expecting user to respond to each of them at some moment of time. By definition UIAlertView is non modal, i.e. the logic of my app continues to execute after making them. When the app would go into background would the popups be automatically saved? It looks like when user responds by clicking the button, correct popup responds even after app goes into bkgr and comes back. Does it mean that the UIAlertView popup ptrs are preserved during save/restore, ie can be reused after restore, OR, there is some mangling done to support clickedButtonByIndex:alert referring to correct popup?
Thanks. Victor
UIAlertView inherits from UIView, as does say a scroll view. These user interface elements are all "saved" when your app goes into the background, and are not mangled in some way. When your app comes back into the foreground all your UI elements work the same.
FYI, this behavior has changed in iOS 4 (in the unlikely event that you're trying to support pre iOS 4): See the "Important" note in the "Overview" section of the UIAlertView documentation.
But, yes, your app is preserved, unless iOS has to shut it down, in which case all bets are off.

Is there anyway to close iphone app just like user press the menu key?

Is there anyway to close iphone app just like user press the menu key?
I already know exit(0) , it works. But user experience not good, I want to scale the window first and then close the app, just like user press the menu key. Is this possible? Thanks!
This is not possible. Apple don't allow it. It's very poor user experience for an app to just exit even if it does look like they've pressed the home button. The user is in control of what happens and when an app exits.
Yes there is a way to close the iPhone app just like user presses the Home Key, But Apple strictly forbids to use this. Anyways here is the code:
[[UIApplication sharedApplication] suspend];
No, there is no way to do this, and quite honestly, there really isn't any good reason to do this. Users expect to control when the app closes, period.
What are you trying to gain by closing the app anyway?

What's the rule under the displaying UIAlert message "app would like to use your current location"?

In my app I have two tabs. The first tab just controller with some functions.
The second tab has MapView with showUserLocation property YES.
As I know in general UIAlert message "app would like to use your current location" is displayed when app is launching, but in my raw app this message has time when I do the firs tap on my second tab.
Would you clarify me how can I manage this issue?
P.S.Sorry, but I didn't find any info about.
Thanks
It's actually better to only request location access when it's necessary. In many apps, some users might not even use the location-based features. Having it only pop up when they hit the second tab is perfectly fine.