9
votes

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

1
Just for clarification, are you testing this on a real iOS device? You can't test notifications with iOS simulator.Dan
@Dan yup I do testing on iPhonekrissanawat
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?Ashwin Mothilal
@krissanawat can you provide us with your full AppDelegate.m file and the react-native code where you define your firebase workflow?Neeko

1 Answers

1
votes

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        
}