React native FCM iOS push notification not delivered
Asked Answered
P

1

9

first of all environment is React native, I try to setup push notification in iOS following instruction from rnfirebase package here what step i do and I do testing on Real iPhone Device

  1. create key

enter image description here

  1. then add to firebase

enter image description here

  1. add Google-service.plist and add setup following from firebase doc

enter image description here

and acivate capabillity enter image description here

  1. then I install pod package

enter image description here

  1. run app got token

enter image description here

  1. use token send on cloud messaging console

notification not delivered I didn't know what wrong because message also send from FCM and what happens on APNS where I get an error just confused

thank for advance

and also try by connecting directly with pusher enter image description here

and also not received again

then try to use Onesignal with same certificate with Firebase is work even on the test message

Pompei answered 1/1, 2020 at 14:54 Comment(6)
Just for clarification, are you testing this on a real iOS device? You can't test notifications with iOS simulator.Powwow
@Powwow yup I do testing on iPhonePompei
Few more questions were your application on the foreground or background? If foreground did you check the event listeners on the App? If background did you try sending it from Firebase console or something else?Unrounded
@Pompei can you provide us with your full AppDelegate.m file and the react-native code where you define your firebase workflow?Refract
@Neeeko appdelegate here -> gist.github.com/krissnawat/4a8fdcb2526434ad3a037237ebe81eec for App.js using get token code -> gist.github.com/krissnawat/c24701c42e8be641aa72bf15196e4723Pompei
Check this article, please: onesignal.com/blog/… If your device is using iOS 13.0 or higher it may be affected by newest changes. Maybe upgrading versions would help, as suggested here: github.com/invertase/react-native-firebase/issues/… Also check this solution github.com/invertase/react-native-firebase/issues/…Cohe
W
1

The token you are using in Pusher doesn't look right. My tokens for remote notifications look like this.

enter image description here

I was just testing silent pushes, but the token would look similar for regular alerts. Here is the code I use to grab the token. My guess is that you are pushing a bad token up to FCM.

fileprivate func convertHexDataToString(_ data: Data) -> String {
    var string: String = ""
    for i in 0..<data.count {
        string += String(format: "%02.2hhx", data[i] as CVarArg)
    }
    return string
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let tokenString = convertHexDataToString(deviceToken)
    #if DEBUG
    print("APN sandbox token: '\(tokenString)'")
    Messaging.messaging().setAPNSToken(deviceToken, type: .sandbox)
    #else
    print("APN prod token: '\(tokenString)'")
    Messaging.messaging().setAPNSToken(deviceToken, type: .prod)
    #endif        
}
Wilone answered 17/1, 2020 at 15:7 Comment(2)
I grab token that generates by rnfirebase package so if package wrong where do i get tokenPompei
These two methods are in AppDelegate. If you add those there and then call to register for push notifications, the operating system will call didRegisterForRemoteNotificationsWithDeviceToken which prints the token. I would focus first on getting pusher to work, then debug FCM. If pusher isn't working then, FCM won't work either.Wilone

© 2022 - 2024 — McMap. All rights reserved.