Application Proxy
beyondappdelegate.m//35_ Local Notice////Created by Beyond on 14-9-12.//Copyright (c) 2014 Com.beyond. All rights reserved.//#import "BeyondAppDelegate.h" @implementation beyondappdelegate-(BOOL) Application: ( UIApplication *) Application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions{UITextView *text = [[ Uitextview Alloc]init]; Text.frame = CGRectMake (40, 0, 240, 300); Text.backgroundcolor = [Uicolor Redcolor]; Text.text = [NSString stringwithformat:@ "didlaunchwithoption\n%@", launchoptions]; [Self.window.rootViewController.view Addsubview:text]; 1. If you click on the icon to enter the application, then the Launchoptions dictionary is nil//2.1, if you click on the local notification for the application, then the Launchoptions dictionary has a value of:/* ... */ 2.2, if other applications jump to the application to open the application, then the Launchoptions dictionary has a value, the value is: NSLog (@ "didlaunchwithoption"); return YES;} /** The following method Didreceivelocalnotification, the premise is called: 1, the application is not closed, still running in the background, or is displayed in 2, the user click on the notification, entered the program (the program is still running, the program is not turned off) 3, if the application is being displayed, This method of */-(void) Application: (UIApplication *) is still called by the app agent when the notification is receivedPplication didreceivelocalnotification: (uilocalnotification *) notification{UILabel *label = [[UILabel alloc] init]; Label.numberoflines = 0; Label.frame = CGRectMake (0, 300, 320, 30); Label.backgroundcolor = [Uicolor Bluecolor]; Label.text = @ "Didreceivelocalnotification"; [Self.window.rootViewController.view Addsubview:label]; NSLog (@ "didreceivelocalnotification");} @end
Controller
beyondviewcontroller.m//35_ Local Notice////Created by Beyond on 14-9-12.//Copyright (c) 2014 Com.beyond. All rights reserved.//#import "BeyondViewController.h" @interface Beyondviewcontroller ()//Add a local notification-(ibaction) addlocalnotice;//Cancel Local notification-(ibaction) cancellocalnotice; @end @implementation beyondviewcontroller//Add a local notification-( ibaction) addlocalnotice{//1. Create notification uilocalnotification *localnote = [[Uilocalnotification alloc] init]; 2. Set the property of the local notification localnote.alertaction = @ "action title"; Action title Localnote.alertbody = @ "LUN Home miss you ~ ~ ~"; Body Localnote.applicationiconbadgenumber = 5; Recurrence interval for local notifications: every minute, every day, every hour ...//localnote.repeatinterval = Nscalendarunitminute; Click "Local Notification", when opening the program, will show the start picture localnote.alertlaunchimage = @ "Default.png"; "Local notification" when to start localnote.firedate = [NSDate datewithtimeintervalsincenow:5]; 3. To register a "local notification" (add) to the app, you must first remove the old one, preventing the repetition of adding uiapplication *app = [UIApplication sharedapplication]; [App Cancelalllocalnotifications]; [App Schedulelocalnotification:localnote];} Cancel local notification-(ibaction) cancellocalnotice{uiapplication *app = [UIApplication sharedapplication]; [App Cancelalllocalnotifications];} @end
turn on notifications, then completely exit the program, click "Local Notifications" to enter the program,
Only the Didfinishlaunchingwithoptions method is called, and the arguments are passed: launchoptions
Does not call Didreceivelocalnotification,
Because this method is called as a precondition:
Notification is received when the app is running or is still running in the background
Ios_35 Local Notifications