Skip to content

not receiving notification and give error code 422 #289

Closed

Description

@ParmarJigarr

'Users with ids 5351459 do not have push notification subscriptions' when sending msg using react native

Activity

  1. ParmarJigarr commented on Jan 25, 2022

    @ParmarJigarr
    Author

    Yes , i have already performed this steps still getting this error in catch block

  2. ccvlad commented on Jan 25, 2022

    @ccvlad
    Contributor

    Attach logs were you do request and get response on subscription. And logs with the error 422

  3. ParmarJigarr commented on Feb 3, 2022

    @ParmarJigarr
    Author

    event_log_61fba775059aea0011c02462.json.zip
    I am able to create session sucessfully , chatting is also working fine , i can also see the push notification token in our admin panel but for some reason i am getting 401 in push notification JSON
    this issue is only facing in IOS side !

  4. ParmarJigarr commented on Feb 7, 2022

    @ParmarJigarr
    Author

    This is event log of successfully send message
    event_log_6200adb8ebf9ca00184a7013.json.zip

  5. ParmarJigarr commented on Feb 22, 2022

    @ParmarJigarr
    Author

    Any update ?

  6. DaveLomber commented on May 3, 2022

    @DaveLomber
    Collaborator

    @ParmarJigarr we brought a new push notifications library which addressed some issues #296

    Please read the details and provide a feedback/comments if any

  7. arnofo commented on Jan 27, 2023

    @arnofo

    Hello @ParmarJigarr, did you ever fix this issue ?

    I'm seeing the exact same error message in the event_log_xxx.json as you did. Thx.

  8. ParmarJigarr commented on Jan 27, 2023

    @ParmarJigarr
    Author

    @arnofo No brother , i am not able to send and receive push notification with connectycube :( , so i had implement push notification by REST API . Thank You

  9. DaveLomber commented on Jan 27, 2023

    @DaveLomber
    Collaborator

    @arnofo could you let me know which issue you are having now

  10. arnofo commented on Jan 27, 2023

    @arnofo

    Here is the log from your backend :
    event_log_63d2baf5669b24002fd6130a.zip

    This issue i am seeing is only on IOS.

    I am using notifee with remote notification support as the library for receiving notifications :
    https://notifee.app/react-native/docs/ios/remote-notification-support

    I was having issues with your library when opening (press action) notifications (especially when the app was in the background).

    Everything works fine on Android.

    I am now trying to test it on IOS but the notification never seems to be pushed to phone.

    I believe it is not sent by APNs to the phone. Probably because of the 401 seen in the event_log_xxx.json.

  11. DaveLomber commented on Jan 29, 2023

    @DaveLomber
    Collaborator

    @arnofo according to backend log, the notification is failed to delivery with error status code 401, so the APNS server failed to accept the push request by some reason.

    401 generally means Unauthorised. There could be one main reason:

    • could you check/show us your certificate/token settings at Admin panel. It could that the data you set is wrong , which I think should be a case here
  12. arnofo commented on Jan 30, 2023

    @arnofo

    Here it is :

    Screenshot 2023-01-30 090439

    Yes that was my understanding of the 401 as well but without a more precise error message, i am having a hard time finding what exactly goes wrong.

    These kind of 401 mean that we cannot push to the APNs server or that the push message is rejected by the specific device targeted ?

  13. DaveLomber commented on Jan 30, 2023

    @DaveLomber
    Collaborator

    @arnofo one more question
    when you subscribe to pushes via 'create subscription' API, do you pass bundle_id or not?
    If yes, is it equal to bundle_id of you APNS certificate?

  14. arnofo commented on Jan 30, 2023

    @arnofo

    No i do not pass bundle_id. I am going to try to debug again tomorrow, i will let you know if i find anything else.

  15. DaveLomber commented on Jan 30, 2023

    @DaveLomber
    Collaborator

    @arnofo another idea is that you use wrong device token when subscribe to push notifications. It should be around 64 chars.
    Could you show an example of your device token so we can compare?

    Also, please provide a code snippet how you obtain device token via notifee lib. It might be you are using wrong method. Let's check together

  16. arnofo commented on Feb 1, 2023

    @arnofo

    Hello @DaveLomber

    You were right i was not getting the proper token for IOS. I misunderstood the full scope of how the push notifications worked with ConnectyCube. (i did not do the initial setup on the project i am working on)

    Connectycube uses firebase to send Android push notifications and APNs directly for IOS push notifications.

    In my code, i was getting a token from Firebase for both platform :

    // Get the token from FCM
    const token = await messaging().getToken();

    I should have been using the package @react-native-community/push-notification-ios :

    // Request permissions (required for iOS)
    // requestPermissions will trigger registerForRemoteNotifications implicitly.
    // register listener will get device token.
    PushNotificationIOS.requestPermissions({
          alert: true,
          badge: true,
          sound: true,
    });
    
    PushNotificationIOS.addEventListener('register', (token) => {
          const token = token;
    });

    Then you use the token to create the subscription on Connectycube.

    Few other clues that might help people that wanted to use notifee:

    • I used messaging().onMessage and messaging().setBackgroundMessageHandler to listen for firebase push notification
    • I used PushNotificationIOS.addEventListener('notification', ... ) to listen for APNs push notification
    • For both Firebase and APNs listeners, i call a function that displays the notification with notifee : notifee.displayNotification
    • I handle press actions and openings with notifee.onForegroundEvent and for completeness i also use notifee notifee.getInitialNotification when the app is opening from quit state.

    (I still have a few edge cases to handle but most of the solution is working now)

    Thanks for the help @DaveLomber.

  17. DaveLomber commented on Feb 1, 2023

    @DaveLomber
    Collaborator

    @arnofo thanks for confirming it!

    For someone who might use the notifee lib as well - we added a ref to this GitHub issue from documentation https://developers.connectycube.com/reactnative/push-notifications?id=notifee-lib

    I will close the issue for now then, feel free to open another one for any other issues/questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions