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

Unable to Register on IOS #196

Open
tomylee001001 opened this issue Feb 3, 2018 · 9 comments
Open

Unable to Register on IOS #196

tomylee001001 opened this issue Feb 3, 2018 · 9 comments

Comments

@tomylee001001
Copy link

tomylee001001 commented Feb 3, 2018

Which platform(s) does your issue occur on?

  • iOS
  • Xcode version 9.2
    -Both simulator and iphone

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

  • CLI: 4.4.2
  • Cross-platform modules: tns-ios : 3.2.0
  • Plugin(s): "dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/router": "~5.0.0",
    "allow-publish": "^1.0.4",
    "email-validator": "^1.1.1",
    "nativescript-angular": "~5.0.0",
    "nativescript-cardview": "^2.0.3",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-geolocation": "^4.2.2",
    "nativescript-google-maps-sdk": "^2.4.3",
    "nativescript-handle-file": "^1.0.0",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-permissions": "^1.2.3",
    "nativescript-push-notifications": "^1.0.0",
    "nativescript-socket.io": "^0.9.0",
    "nativescript-theme-core": "1.0.4",
    "nativescript-videoplayer": "^3.1.0",
    "reflect-metadata": "0.1.10",
    "rxjs": "~5.5.2",
    "tns-core-modules": "^3.4.0",
    "tns-platform-declarations": "^3.4.0",
    "zone.js": "~0.8.2"
    }
    "devDependencies": {
    "@angular/compiler-cli": "5.1.3",
    "@ngtools/webpack": "~1.9.3",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "~3.0.0",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-dev-typescript": "0.6.0",
    "nativescript-dev-webpack": "^0.8.0",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.1.0",
    "typescript": "2.5.2",
    "webpack": "~3.6.0",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1"
    }

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

@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
Copy link
Contributor

lini commented Feb 16, 2018

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
Copy link
Author

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
Copy link

skhye05 commented Feb 28, 2018

Hi, I am getting the same issue.

@relez
Copy link

relez commented Mar 1, 2018

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
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants