NativeScript / push-plugin

Contains the source code for the Push Plugin.
Apache License 2.0
123 stars 45 forks source link

Unable to Register on IOS #196

Open tomylee001001 opened 6 years ago

tomylee001001 commented 6 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

i am try to send push notification to my project.in android it works but i cannot register in the ios. i am trying from Mac OSX 10.13.3 and xcode 9.2. i did everything from the documentation but when i try to register push notificaion it fails without any error message. also after i build my app with "tns build ios" and open .xcodeproj file in the platform/ios, i enable the push notification in the Capabilities. but after i run my app either in my iphone or simulator with "tns run ios" then re-open .xcodeproj file and capabilities i see an error like the attachmenti send.

Is there any code involved?

const iosSettings = { senderID: "[sender id]", badge: true, sound: true, alert: true, 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) => { alert(JSON.stringify(message)); } };

        PushNotifications.register(iosSettings, (token: String) => {
            console.log("Device registered. Access token: " + token);

            // Register the interactive settings
            if (iosSettings.interactiveSettings) {
                PushNotifications.registerUserNotificationSettings(() => {
                    console.log('Successfully registered for interactive push.');
                }, (err) => {
                    console.log('Error registering for interactive push: ' + JSON.stringify(err));
                });
            }
        }, (errorMessage: any) => {
            console.log("Device NOT registered! " + JSON.stringify(errorMessage));
        });
screen shot 2018-02-03 at 12 46 42
TheOnlyMatt commented 6 years ago

You have to set a valid provisionning profile corresponding to your app's bundle identifier, having previously enabled the push notifications for the app in the apple developper account.

tomylee001001 commented 6 years ago

hi @TheOnlyMatt if you refering to this; capture i already included "Push Notifications" to the provisinal profiles of both development and distrubition of my app. if its not can you tell me is there another place i need to set "Push Notifications". thanks.

TheOnlyMatt commented 6 years ago

Ok good, I didn't noticed, but you have a little button "fix issue" on your screenshot. It will add <key>aps-environment</key><string>development</string> to platforms/ios/YourAppName/YourAppName.entitlements file. After that, copy that file to your app/App_Resources/iOS folder.

Tell me if it solves your problem

tomylee001001 commented 6 years ago

@TheOnlyMatt i tried that without success but by doing this i think i find the problem. before "tns run ios" the AppName.entitlements file had tags like this;

aps-environment development

but after the "tns run ios" AppName.entitlements file became like this;

lini commented 6 years ago

If you still experience this issue please try updating to the latest version of the plugin. It includes code that will automatically update the .entitlements file in the iOS project and should fix the error while registering the device.

tomylee001001 commented 6 years ago

hi @lini Thanks for update. i updated the plug-in but i still cannot register on IOS. Also there is something i notice; in the example usage of IOS there is no "senderID" parameter inside "iosSettings" but if i do not add that parameter i cannot build my app. i am getting Typescript compiler error. is this normal or something wrong with my settings.

skhye05 commented 6 years ago

Hi, I am getting the same issue.

relez commented 6 years ago

Hi @tomylee001001, iosSettings should be assignable as a IosRegistrationOptions, thats why there is an error in TypeScript when you try to compile, the simplest example could something like this:

{
      badge: true,
      sound: true,
      alert: true,
      clearBadge: true,
      interactiveSettings: {
          actions: [],
          categories: []
      },
      notificationCallbackIOS: (message: any) => {
          this._feedback.success({message: message});
      }
}

Same as you, I am trying to make Push Notifications work but it is not registering the device.

Any updates guys?

lumayara commented 6 years ago

I am having the same issue except my push notifications session in xcode has no issues... but when I ran the app it doesn't show me the alert saying my device is registered.