HI、
私はこの問題を解決しました。 これは私がやったことです。 アプリケーションはプッシュ通知を受信すると、launchOptions NSDictionaryに通知を格納しました。
/* Push notification received when app is not running */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *params=[[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"contTag"];
if ([params length] > 0) {//app launch when VIEW button of push notification clicked
//do some processing
........
WebViewController *webViewController =
[[WebViewController alloc] initWithNibName:@"WebView" bundle:[NSBundle mainBundle]];
// Put your custom code
[[self navigationController ] pushViewController:webViewController animated:YES];
[window addSubview:navigationController.view];
/* Remote Notification Received while application was open. */
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"remote notification: %@",[userInfo description]);
NSString *contentsInfo = [userInfo objectForKey:@"contTag"];
NSLog(@"Received contents info : %@", contentsInfo);
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);
NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
//-----------------------APNS HANDLE----------------
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive){
NSLog(@" It is in active state");
application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
}
else {
if ([contentsInfo length] > 0) {
// Do whatever u want for push notification handle
}
注: ここcontTagは、プッシュ通知のペイロードのためのサーバ側で設定したキーです。 Uはサーバー側で任意のキーを設定できます。
身体を助けることを願っています。 ありがとうございました