send UIAlert from background mode - iphone

I'm currently using local notification to indicate incoming call from background mode. That's works fine, but this is what i see, when skype got a call in background mode:
So looks like it possible to show UIAlert from background and anybody can answer me how?

No you can not display an UIAlertView from the background, but you can scheudule a UILocalNotification.
Just set the fireDate property of the UILocalNotification to the current date and it will be displayed directly.

Related

How does iOS handle local Notification in background mode?

didReceiveLocalNotification is called when a notification is fired in active mode but how does iOS handles notification in background mode (not active mode, application is terminated may be) before app is active by swiping or clicking the notification.
Or
Mainly I want to know how to conditionally handle local notification to be on/off (off means not to cancel previous notification but just don't fire it) in background Mode?
I am currently checking this condition in didReceiveLocalNotification but that way I am not able to handle it in background mode?
You can check that is your app started by clicking on local notification in didFinishLaunchingWithOptions method in AppDelegate.m file.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
// your code
}
}
If application is running Alerts won't be shown automatically - you have to handle that manually using the functions you mentioned.
When application is in background or not running iOS will show your local notifications in notifications center and present them according to user settings - as a banner or alert.
Best read this:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction.html
When your app is in the background iOS will handle the notification (Local or Push) and your app can not access them at all.
Only after your app is started will you be able to direct if the user select a notification.

Show AlertView dialog from UILocalNotification

In my app there should be an alarm when a certain distance is covered. Originally, when the conditions are met, I wanted to move the app to the foreground, show an AlertView and play a sound. Due to answers to my former post I've implemented UILOcaLnotifications and it works fine for playing an AlertSound. Even when my app is in the background and thats great. One issue remains unsolved at this moment. I really want to popup a dialog (AlertView) when the conditions are met.
At this moment the ALert message is shown at the top of the screen (like a received message or missed call) but I want to present the user with a dialog (like in the clock app)
Does anyone knows a solution to this question? Help is most appreciated.
Did you try to assign alertBody and alertAction?
notification.alertBody = #"Some message";
notification.alertAction = #"View"; //title of action button
notification.hasAction = YES; //it YES by default

Remove LocalNotification Badge Number from launcher icon

I am trying to add a feature in app in which whenever i made a note, it will Call a UILocalNotification after few days (Hardcoded). Now, on launcher Icons i can see a red badge with marker "1". How can I remove this badge?
Best Regards
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
Add that line in whatever code handles the user's interaction with the local notification. If you want the badge to be cleared when the local notification fires, you can't (because setting the notification's applicationIconBadgeNumber property to 0 would simply mean "don't change the existing badge.")

How to disable UILocalNotification in iPhone for some time?

I have implemented one reminder iphone applicaion in which I have used local notification for reminder.
In this application their one functionality alert on/off.
So when user set on then user get notification and if its off then user can get notification.
I have done googling but not got sucess.
Can you give me idea for that is it possible or not.
Thanks in advance
Do you have other notifications in your appln.
If you don't have other notification in your app than,
Do one thing,
When you set OFF
- cancel all the notification
- calculate the time difference of current time & your notification firing time. set this in to some variable.
when you set it ON
- reschedule your Notification based on the time which you have saved earlier.
I am considering that you know how UISwitch works, according to switch position
UILocalNotification *localNotif;
//if switch is on
localNotif = [[UILocalNotification alloc] init];
//else if localNotif is not equal to null then
localNotif = nil;
You can start a timer which continuously check switch position and do the above stuff that depends on your coding.

UIAlertView raised from background

I'm developing an Alarm App.
When the alarm starts sounding I pop up an UIAlertView in order to offer the user the option to stop it. But when the app is in background the UIAlertView doesn't appears.
How can I do a UIAlert similar to the alert that uses the iOS Alarm?
Thanks!!
You could start reading about this: Apple documentation about notifications. You are probably most likely interested in local notification.