http://www.codeproject.com/Articles/715415/Sending-Push-Notifications-from-a-Drupal-site
Notification are sent via Google Cloud Messaging (GCM)
Steps:
- Setting up Google Cloud Messaging
- Push Configuration in ACS Console
- CloudPush Module Implementation
- Retrieve Device Token
- Cloud User Login
- Subscribe a Channel
1. Setting up GCM
- create Google API project in developer console
- https://developers.google.com/mobile/add
enable GCM service for your app (require app name and package name)
- obtain the Server API key and Sender ID
- download configuration file (google-services.json) and copy & paste to app/ or mobile/ module directory in Android project
- In developer console, go to app > Services & APIs > link SenderID (copy & paste the server API key)
2. Push Configuration in ACS Console
- login to Appcelerator dashboard
- select Apps from pull-down menu
- select "push notification" on left sidebar
- select "Android Push" and enter the API Key and SenderID obtained in Step 1
3. CloudPush Module Implementation
- open project in Appcelerator Studio
- add module ti.cloudpush, ti.cloud
- edit tiapp.xml to add property "acs-push-type", "acs-push-type-development", "acs-push-type-production" and set its value to gcm
Remark: If got permission error, make sure proper permission has been added in tiapp.xml:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4. Retrieve Device Token
- add code in project to retrieve device token (utility/PushNotificationConfig)
沒有留言:
張貼留言