2017-09-27 54 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中的 –

相关问题