IOS-click push message jump processing, ios-click message jump
When the user clicks the notification message to enter the application
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptionslaunchOptions
The userInfo information of the push message is displayed.
NSDictionary* remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
Obtain the content of the push message. If remoteNotification is not empty, it indicates that the user enters through the PUSH message, then an attribute can be declared.
@property (nonatomic) BOOL isLaunchedByNotification;
It is used to identify whether a user enters the application by clicking the notification message. At this time,
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
It will be called, and iOS7 can be used.
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
Because MainViewController has been initialized when this method is called, we can register a listener for pushing messages in MainViewController to display the corresponding view, as shown below:
// Subscribe to the display view message. A branch view [[nsicationcenter center defacenter center] addObserver: self selector: @ selector (presentView :) name: @ "PresentView" object: nil] is directly opened. // The pop-up message box prompts you to subscribe to a notification message. This function is mainly used when you use an application. In the displayed dialog box [[nsnotifcenter center defacenter center] addObserver: self selector: @ selector (showNotification :) name: @ "Notification" object: nil];
Therefore, in the didReceiveRemoteNotification of AppDelegate, different display methods can be notified by judging isLaunchedByNotification.
The brain supplements the code that is pushed temporarily to play the audio without stopping the vibrate sound (not playing the music)
First include the header file
#import <AudioToolbox/AudioToolbox.h>
Register a sound (in this example, the default 1007 is used directly)
@ Property (nonatomic, assign) SystemSoundID soundID; NSString * path = [[NSBundle mainBundle] pathForResource: soundName ofType: nil]; invoke (_ bridge CFURLRef) [NSURL fileURLWithPath: path], & _ soundID); resolve (_ soundID, NULL, NULL, soundCompleteCallback, NULL); // The core code can be repeated to execute AudioServicesPlaySystemSound (audio); AudioServicesPlaySystemSound (_ soundID ); // block is used for callback (_ soundID, NULL, NULL, soundCompleteCallback, NULL); function call void soundCompleteCallback (SystemSoundID soundID, void * clientData) {AudioServicesPlaySystemSound (callback ); audioServicesPlaySystemSound (soundID);} // stop playing-(void) Audio :( SystemSoundID) soundID {audio (kSystemSoundID_Vibrate); audio (soundID );}