Skip to content
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
This repository was archived by the owner on Feb 7, 2019. It is now read-only.

Apns notification error: 'InvalidToken' #240

Open

Description

@dpdragnev

We are experiencing an issue with sending notifications to our test iOS device. Everything works well on Android. Here is our environment:

nodejs: 8.9.4
npm: 5.8.0
tns-ios: 4.1.0
push-plugin: 1.0.4
tns: 4.1.2

The certificates, the provisioning profile, and the p12 files were generated on the same machine (iMac).
The correct certificate and provisioning profile are set up in Sidekick. We are testing it via pushtry.com as well as locally via our API.

Here is how we generate the token:

    //iOS
    let iosSettings = {
      badge: true,
      sound: false,
      alert: true,
      clearBadge: false,
      interactiveSettings: {
        actions: [
          {
            identifier: "READ_IDENTIFIER",
            title: "Read",
            activationMode: "foreground",
            destructive: false,
            authenticationRequired: true
          },
          {
            identifier: "CANCEL_IDENTIFIER",
            title: "Cancel",
            activationMode: "foreground",
            destructive: true,
            authenticationRequired: true
          }
        ],
        categories: [
          {
            identifier: "READ_CATEGORY",
            actionsForDefaultContext: ["READ_IDENTIFIER", "CANCEL_IDENTIFIER"],
            actionsForMinimalContext: ["READ_IDENTIFIER", "CANCEL_IDENTIFIER"]
          }
        ]
      },
      notificationCallbackIOS: (message: any) => {
        //console.log('Push notification from iOS: ', message);
        //let response = JSON.parse(message);
      }
    };

    pushPlugin.register(
      iosSettings,
      (token: String) => {
        appSettings.setString(SettingsEnum.DEVICE_TOKEN.toString(), token.toString());

        pushPlugin.registerUserNotificationSettings(() => { }, err => { });
      },
      function (errorMessage: any) {
        console.log("Error from Apple notification: ", errorMessage);
      }
   );```

What are we missing?

Thank you.

Activity

  1. tbozhikov commented on Aug 3, 2018

    @tbozhikov
    Contributor

    Hi @dpdragnev You could check online for such errors (like this thread) as it is more like a setup issue rather than plugin issue.

  2. dpdragnev commented on Aug 3, 2018

    @dpdragnev
    Author

    Hello @tbozhikov

    I am using a Mac and I followed the instruction from this article to the letter.

    The token is generated properly in the correct format and I can verify that the plugin successfully completes the call to registerUserNotificationSettings.

    The notifications are enabled on the device and in XCode as well as in the app profile in developer.apple.com.

    I am really running out of places to look at. Any suggestion would be greatly appreciated.

    Thank you.

  3. tbozhikov commented on Aug 10, 2018

    @tbozhikov
    Contributor

    Hi @dpdragnev
    If you are not using interactive push notifications in your project, you may try implementing the push functionality with the {N} Firebase plugin - not only because we are going to deprecate the push-plugin in the future, but also because the Firebase plugin promotes another way of sending/testing your push notifications (through the Firebase console for both Android and iOS). This may make difference in your setup and work with no errors.
    Let us know if you try this way and what is the outcome.

  4. dpdragnev commented on Aug 10, 2018

    @dpdragnev
    Author

    Thank you @tbozhikov

    I will look into it and will report back.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions