Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Device should register, Push Notification should receive on IOS. #926

Closed
cwMohneesh opened this issue May 25, 2016 · 20 comments
Closed

Device should register, Push Notification should receive on IOS. #926

cwMohneesh opened this issue May 25, 2016 · 20 comments

Comments

@cwMohneesh
Copy link

Expected Behaviour

Device should register, Push Notification should receive on IOS ie. iphone etc.

Actual Behaviour

Not getting tocken, when app launch, Showing error "ReferenceError: Can't find variable: PushNotification" while debugging on ios device.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

ios - 9.3

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Cordova CLI version and cordova platform version

cordova --version               5.1.1                     # e.g. 6.0.0
cordova platform version android                     # e.g. 4.1.1

Plugin version

cordova plugin version | grep phonegap-plugin-push   1.4.3

Sample Push Data Payload

Sample Code that illustrates the problem

Logs taken while reproducing problem

@macdonst
Copy link
Member

@cwMohneesh the installation of the plugin must have failed if the PushNotification object is not available. Need more info from you in order to debug.

@cwMohneesh
Copy link
Author

@macdonst I am developing a cross platform app in android and ios using intel xdk. I installed this plugin through intel xdk. This plugin works on android very well but not registering device on ios.
I have already configured apple developer settings and created .pem file and passphrase for APN.

Please guide me where am I doing wrong. If any process for ios implementation is available for this plugin Please share with example.

Thanks a lot.

@macdonst
Copy link
Member

@cwMohneesh I'm sorry but you'll need to debug with the Intel XDK guys. I don't have an infinite amount of time to debug all the third party build services.

@cwMohneesh
Copy link
Author

@macdonst Thanks for your precious time. I 'll try to connect with Intel XDK guys.

@macdonst
Copy link
Member

Hey @tony-- can you take a look at this issue?

@tony--
Copy link

tony-- commented May 25, 2016

Probably won't have time until tomorrow next week - will update after I try to reproduce.

Update: adjusted estimate 😞

@macdonst
Copy link
Member

@tony-- no problem, thanks for looking at it whenever you get a chance.

@joedeveloper
Copy link

joedeveloper commented May 30, 2016

I ran across a similar issue, one of the things that I noticed when trying to resolve it was the following when re-adding the ios platform:
Plugin doesn't support this project's cordova-ios version. cordova-ios: 3.9.2, failed version requirement: >=4.0.0

Skipping 'phonegap-plugin-push' for ios

Updating to the newest phonegap-cli ( 6.2.5 in my case ) let me build a working ios app via xcode.
npm install -g phonegap

I also updated config.xml ( for build.phonegap ) to include the following:
<preference name="phonegap-version" value="cli-6.1.0" />

@tony--
Copy link

tony-- commented Jun 1, 2016

Just wanted to give an update...
I'm trying to get the plugin working with vanilla Cordova in order to establish a baseline before trying it with Intel XDK.
Using the sample template + cordova-ios 4.1.1 + phonegap-plugin-push 1.6.4 on an iPhone 6 with iOS 9.3.1, I am getting a deviceToken so it seems things are working 👍
For the server side I am using the ruby example (example/server/pushAPNS.rb updated with deviceToken and my .pem file) which runs without any error, but I am not receiving any notifications. 🎱

I asume this is an issue on my side (probably with my server?) and am troubleshooting.

@tony--
Copy link

tony-- commented Jun 1, 2016

I got the plugin working with vanilla Cordova (sent and received notifications on both dev and prod environments). For reference, my problem was that I wasn't using the correct provisioning profile and I had the wrong format for the device id.

I'll try with Intel XDK later tonight or tomorrow.

@macdonst
Copy link
Member

macdonst commented Jun 1, 2016

Thanks @tony-- your assistance is appreciated.

@tony--
Copy link

tony-- commented Jun 2, 2016

I made a new app in Intel XDK, added the plugin, edited the configuration, built the app, installed the app and received a push notification.

Test Environment
Intel XDK 3357 (Mac, OS X 10.11.5)
iPhone 6 (iOS 9.3.1)

  1. Do pre-requisite setup on the iOS Provisioning Portal. Refer to this guide or Apple docs for detailed steps.
    a. make a new App ID (you'll need to set this in Intel XDK config later)
    b. enable push notifications
    c. iOS Distribution cert: create (if needed), download and install (if needed), export as a .p12 (set and remember the password as you'll need this to import into Intel XDK later)
    NOTE: Intel XDK does not support Development certs, so you MUST use your Distribution cert.
    d. Make an AdHoc Provisioning Profile using your App ID from (1a) and your cert from (1c). Make sure your test device is enabled. Download and save with a name you will recognize. (you'll need to add this to your Intel XDK project later)
    e. make a push cert, download it, install it, export it to .p12, convert it to .pem (this is for the push server that will send the notification - you'll need this later to test your Intel XDK app)
  2. In Intel XDK, make a new Cordova CLI 5.4.1 project using the HTML5+Cordova Blank Template, then replace the contents of www with the contents of www from the PhoneGap Push Template.
  3. Delete www/config.xml (optional? Intel XDK does not use config.xml)
  4. Intel XDK Project Settings
    a. set the iOS App ID to match the App ID from (1a)
    b. (if needed) import your .p12 from (1c) - Account Settings->Developer Certificates->iOS, then select it as the Developer Certificate for the project
    c. Select "adhoc" for Provisioning Profile
    d. copy your provisioning profile from (1d) into www/, then click "Ad hoc Provisioning Profile" and select the profile
    e. Add the latest version of phonegap-plugin-push as a "Third-Party Plugin" (at time of testing this was 1.6.4)
    f. After the plugin is added, you will need to edit plugins/phonegap-plugin-push/plugin.xml. Intel XDK 3357 does not support plugins with gradle references, so the gradle reference must be commented out (this will prevent this version of the plugin from working for Android but is needed for the iOS build to succeed):
    <!--framework src="push.gradle" custom="true" type="gradleReference" /-->
    A future version of Intel XDK will support gradle references.
  5. XDK Build Tab
    a. Enable iOS build (click the checkmark)
    b. Unlock your iOS certificate (click the lock and enter the password from (1c))
    c. click Start Builds
    d. once the build completes, download and install the app
  6. connect test device by USB and open XCode Devices window (probably could also use Safari Web Inspector + Cordova Console plugin) - start the app and a log message should be written into the console that looks like "Push Plugin register success: <XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX>"
  7. exit the app (close with home button then swipe it off the multitask view)
  8. The angle brackets and everything between (from (5)) is the device token - copy it into a text file
  9. Add the device token to your server and send a push notification
    a. I used phonegap-plugin-push/example/server/pushAPNS.rb for this
    b. APNS.host = 'gateway.push.apple.com'
    c. APNS.pem = 'PGPush926Prod.pem' #path to your pem file from (1e)
    d. device_token = '<XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX>' #the device token from (7)
    e. edit the alert message and badge number
    f. you probably need to install the required gem (gem install pushmeup)
    g. send the notification (ruby pushAPNS.rb)
  10. See notification on device!

That should be it, but I probably forgot something, so let me know if more information is needed.

@xmnboy
Copy link

xmnboy commented Jun 2, 2016

@tony and @macdonst -- The XDK build system currently provides the equivalent functionality of the gradle script that is part of this plugin (at least, the first part of the gradle script, which sets the push services ID equal to the app ID). So removing the reference to the gradle script from the plugin.xml file will work on Android when built with the XDK build system.

If I understand that last part of that gradle script, correctly, this part of that gradle script...

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:23.4.0'
    }
}

...may also not be a problem, but I'm not absolutely sure.

I'm interpreting that part of this plugin's gradle script to mean that you require specifically version 23.4.0 of the android v4 support lib, but I'm guessing that using a later version would also work? Is that correct? Or am I smoking something? Please clarify that point. I believe we have a later version of those lib files installed on our system.

@xmnboy
Copy link

xmnboy commented Jun 2, 2016

@macdonst -- I take that back, as of today, the most recent production version of that lib is 23.4.0, but it will eventually be updated to 24.0.x. If we do not honor that part of the gradle script, when we're building against a later version of that lib, do you expect problems?

@macdonst
Copy link
Member

macdonst commented Jun 3, 2016

@xmnboy Google released a beta version of that lib and it is not compatible with the current version of Play Services see issue #909 for more details. As soon as Google fixes this issue I will remove the part of the Gradle script that forces people to use 23.4.0. So for now do not build with 24.x.y as it will crash your app.

macdonst added a commit that referenced this issue Jun 3, 2016
@macdonst
Copy link
Member

macdonst commented Jun 3, 2016

Thanks @tony-- I've added your excellent write up to the docs, IntelXDK, and I'm going to consider this bug close.

@macdonst macdonst closed this as completed Jun 3, 2016
@xmnboy
Copy link

xmnboy commented Jun 3, 2016

Thanks for the clarification, Simon (@macdonst).

@ronaiza-cardoso
Copy link

@tony-- you said here

connect test device by USB and open XCode Devices window (probably could also use Safari Web Inspector + Cordova Console plugin) - start the app and a log message should be written into the console that looks like "Push Plugin register success: <XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX>"

the device token is: XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX

or this: 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320

@tony--
Copy link

tony-- commented Feb 13, 2017

@yesroh Please refer to step 8:

The angle brackets and everything between (from (5)) is the device token - copy it into a text file

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

6 participants