UNPKG

6.67 kBMarkdownView Raw
1# Cloud Build Services
2
3- [PhoneGap Build Support](#phonegap-build-support)
4 - [Including the plugin](#including-the-plugin)
5 - [Adding Resources](#adding-resources)
6- [IntelXDK Support](#intelxdk-support)
7- [Ionic Cloud Build](#ionic-cloud-build)
8
9## PhoneGap Build Support
10
11> PhoneGap Build now support version 1.9.0 of the plugin.
12
13### Including the plugin
14
15Including this plugin in a project that is built by PhoneGap Build is as easy as adding (replacing `123456789` with your own, that is):
16
17```xml
18<preference name="android-build-tool" value="gradle" />
19<plugin name="phonegap-plugin-push" source="npm">
20 <param name="SENDER_ID" value="123456789" />
21</plugin>
22```
23
24into your app's `config.xml` file. PhoneGap Build will pick up the latest version of phonegap-plugin-push published on npm. If you want to specify a particular version of the plugin you can add the `spec` attribute to the `plugin` tag.
25
26```xml
27<preference name="android-build-tool" value="gradle" />
28<plugin name="phonegap-plugin-push" spec="~1.4.5" source="npm" />
29```
30
31Note: version 1.3.0 of this plugin begins to use Gradle to install the Android Support Framework. Support for Gradle has recently been added to PhoneGap Build. Please read [this blog post](http://phonegap.com/blog/2015/09/28/android-using-gradle/) for more information.
32
33### Adding resources
34
35Because PhoneGap Build does not support running hooks if you want to include custom image or sounds you will need to use a *beta* feature to include these files.
36
37#### Android
38
39To add custom files, create a directory called `locales/android/` in the root of your PGB application zip / repo, and place your resource files there. The contents will be copied into the Android `res/` directory, and any nested sub-directory structures will persist. Here's an example of how these files will be compiled into your APK:
40
41```
42<www.zip>/locales/android/drawables/logo.png --> <android_apk>/res/drawables/logo.png
43<www.zip>/locales/android/raw/beep.mp3 --> <android_apk>/res/raw/beep.mp3
44<www.zip>/locales/android/values-fr/strings.xml --> <android_apk>/res/values-fr/strings.xml
45```
46
47Existing directories will be merged, but at this time any individual files you include will overwrite their target if it exists.
48
49## IntelXDK Support
50
511. Do pre-requisite setup on [the iOS Provisioning Portal](https://developer.apple.com/account/ios/identifier/bundle). Refer to [this guide](https://www.raywenderlich.com/123862/push-notifications-tutorial) or Apple docs for detailed steps.
52a. make a new App ID (you'll need to set this in Intel XDK config later)
53b. enable push notifications
54c. 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)
55**NOTE**: Intel XDK does not support Development certs, so you MUST use your Distribution cert.
56d. 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)
57e. 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)
58
592. 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](https://github.com/phonegap/phonegap-template-push/tree/master/template_src/www).
60
613. Delete www/config.xml (optional? Intel XDK does not use config.xml)
62
634. Intel XDK Project Settings
64a. set the iOS App ID to match the App ID from (1a)
65b. (if needed) import your .p12 from (1c) - Account Settings->Developer Certificates->iOS, then select it as the Developer Certificate for the project
66c. Select "adhoc" for Provisioning Profile
67d. copy your provisioning profile from (1d) into www/, then click "Ad hoc Provisioning Profile" and select the profile
68e. Add the latest version of phonegap-plugin-push as a "Third-Party Plugin" (at time of testing this was 1.6.4)
69f. **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):
70`<!--framework src="push.gradle" custom="true" type="gradleReference" /-->`
71A future version of Intel XDK will support gradle references.
72
735. XDK Build Tab
74a. Enable iOS build (click the checkmark)
75b. Unlock your iOS certificate (click the lock and enter the password from (1c))
76c. click Start Builds
77d. once the build completes, download and install the app
78
796. 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\>"
80
817. exit the app (close with home button then swipe it off the multitask view)
82
838. The angle brackets and everything between (from (5)) is the device token - copy it into a text file
84
859. Add the device token to your server and send a push notification
86a. I used [phonegap-plugin-push/example/server/pushAPNS.rb](https://github.com/phonegap/phonegap-plugin-push/blob/master/example/server/pushAPNS.rb) for this
87b. APNS.host = 'gateway.push.apple.com'
88c. APNS.pem = 'PGPush926Prod.pem' #path to your pem file from (1e)
89d. device_token = '\<XXXXXXXX 19b101a3 71590c03 9ea7f446 50eb8409 19ac24bb c1ec1320 XXXXXXXX\>' #the device token from (7)
90e. edit the alert message and badge number
91f. you probably need to install the required gem (`gem install pushmeup`)
92g. send the notification (`ruby pushAPNS.rb`)
93
9410. See notification on device!
95
96## Ionic Cloud Build
97
98Users have reported issues with Ionic Cloud Build. Apparently there are some differences in the way variables are handled. If your app has an issue where the `PushNotification` object can't be found try the following.
99
1001. Remove the inclusion of `phonegap-plugin-push` from config.xml. That is delete lines that look like this:
101
102```
103<plugin name="phonegap-plugin-push" spec="~1.9.1">
104 <variable name="SENDER_ID" value="xxx"/>
105</plugin>
106```
1072. Add the following lines into `package.json` in the `cordovaPlugins` array.
108
109```
110{
111 "variables": {
112 "SENDER_ID": "xxx"
113 },
114 "locator": "phonegap-plugin-push"
115}
116```