2017-09-27 55 views
0

我已經在我的Objective-C項目中添加了firebase。集成成功,但我無法在iPhone的通知欄中顯示通知。didReceiveRemoteNotification未在Firebase中調用?

當到達通知調用此方法,我也得到數據有..

- (void)messaging:(FIRMessaging *)messaging didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage { 

    NSLog(@"FCM Received data message: >> %@", [remoteMessage appData]); 


} 

但是這種方法沒有叫......

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { 


    } 

回答

0

你確定你的有效載荷包含notification關鍵像這樣

{ 
    "to" : " ...", 
    "notification" : { 
     "body" : "great match!", 
     "title" : "Portugal vs. Denmark", 
     "icon" : "myicon" 
    }, 
    "data" : { 
     "Nick" : "Mario", 
     "Room" : "PortugalVSDenmark" 
    } 
    } 

沒有notification鍵在你的p ayload didRecieveRemoteNotification方法不會觸發。

檢查這些更多的信息12

+0

{ 「collapse_key的」= 「捆綁ID」; from = 23123213; notification = { badge = 1; body =「身體在這裏」; e = 1; icon = myicon; sound = default; sound2 =「defalut sound」; subtitle = 1; title =「teasdfasasdf」; }; } –

+0

您正在使用哪個iOS版本。如果您使用的是iOS 10.0或更高版本,請檢查此問題https://stackoverflow.com/questions/39600914/push-notification-not-received-when-app-is-in-background-in-ios-10 – Himanth

+0

是的,我是使用11但它仍然不能正常工作...在iOS11中的 –

相關問題