Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native FCM iOS push notification not delivered

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

like image 646
krissanawat Avatar asked Jan 01 '20 14:01

krissanawat


Video Answer


1 Answers

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        
}
like image 83
TALE Avatar answered Oct 19 '22 01:10

TALE