0

I have added firebase in my objective-C project. Integrated successfully, but I can't show notification in notification bar of iPhone.

when notification arrived this method is called and i get data there..

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

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


 }

But this method didn't call...

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


    }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sanjay Mangaroliya
  • 4,286
  • 2
  • 29
  • 33

1 Answers1

1

Are you sure your payload contains notification key like this

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

Without notification key in your payload didRecieveRemoteNotification method will not trigger.

Check these for more info 1 2

Himanth
  • 2,381
  • 3
  • 28
  • 41
  • { "collapse_key" = "bundle id"; from = 23123213; notification = { badge = 1; body = "body is here"; e = 1; icon = myicon; sound = default; sound2 = "defalut sound"; subtitle = 1; title = "teasdfasasdf "; }; } – Sanjay Mangaroliya Sep 27 '17 at 12:54
  • Which iOS version are you using. If you are using iOS 10.0 or more check this question https://stackoverflow.com/questions/39600914/push-notification-not-received-when-app-is-in-background-in-ios-10 – Himanth Sep 27 '17 at 12:58
  • in iOS11 didRecieveRemoteNotification method will not work. you need to handle userNotifications framework – Himanth Sep 27 '17 at 13:09
  • how to do that ? – Sanjay Mangaroliya Sep 27 '17 at 13:22
  • Check this question I have explained here fully https://stackoverflow.com/questions/39600914/push-notification-not-received-when-app-is-in-background-in-ios-10 – Himanth Sep 27 '17 at 13:29