我從服務器發送推送通知,如果應用程序在後臺運行,通知到達並點擊它調用didReceiveRemoteNotification()。爲什麼我會通過launchOption字典獲得Apple推送通知nil?
但是,當我殺了我的應用程序(後按兩下home鍵向上滑動的應用程序,通知到達但攻通知僅僅是直接在屏幕到App家裏,我已經編碼在didFinishLaunchingWithOptions:。launchOptions()像下面
if (launchOptions != nil)
{
NSDictionary* dictionary = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
if (dictionary != nil)
{
NSLog(@"Launched from push notification: %@", dictionary);
NSString *strVendId=[dictionary valueForKeyPath:@"payload.vendor_id"];
UIStoryboard *mainstoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *navController = (UINavigationController *)self.window.rootViewController;
VenderDetailController *vDetail=[mainstoryboard instantiateViewControllerWithIdentifier:@"venDetail"];
vDetail.strVendorId=strVendId;
[navController pushViewController:vDetail animated:YES];
}
}
沒有辦法,我可以調試這是應用程序就會被殺死。也許我得到零字典我不知道。我甚至試圖刪除launchOption零條件,仍然沒有任何幫助。
我使用的目標C而這個問題正在讓我發瘋。
你可以登錄launchOptions並告訴值 – Shubhank
如何實現,如果我殺了應用程序,xcode項目停止。那麼我怎麼能在設備上記錄什麼? –