Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (device)
Viewing all articles
Browse latest Browse all 250

Push notifications in android

0
0

Titanium SDK:3.2.1,Android device:samsung galaxy grand,platform:android,OS:Windows 7

push notifications in android:

I am trying for push notifications in android,I went according to the docs

1)Got the sender id and app key(create server key) from console.developers.google.com

2)pasted the sender id and app key in the Myapps-->name of the project-->manage acs and saved the push notification configuration.

3)Enabled cloud services in the tiapp.xml file and added modules ti.cloud and ti.cloudpush

4)changes in tiapp.xml file:

<property name="acs-oauth-secret-development" type="string">xxxxxxxxg</property>
    <property name="acs-oauth-key-development" type="string">xxxxxxxx</property>
    <property name="acs-api-key-development" type="string">xxxxxxxx</property>
    <property name="acs-oauth-secret-production" type="string">xxxxxxxx</property>
    <property name="acs-oauth-key-production" type="string">xxxxxxxxx</property>
    <property name="acs-api-key-production" type="string">xxxxxxxxxx</property>
<property name="acs-push-type-development" type="string">gcm</property>
    <property name="acs-push-type-production" type="string">gcm</property>
    <property name="acs-push-type" type="string">gcm</property>
<modules>
        <module platform="commonjs">ti.cloud</module>
        <module platform="android">ti.cloudpush</module>
    </modules>
app.js
var CloudPush = require('ti.cloudpush');
var deviceToken = null;
 
// Initialize the module
CloudPush.retrieveDeviceToken({
    success: deviceTokenSuccess,
    error: deviceTokenError
});
 
// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
    deviceToken = e.deviceToken;
}
function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}
 
// Process incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
    alert("Notification received: " + evt.payload);
});
Ti.UI.setBackgroundColor('#fff');
var win = require('/ui/views/login').createFirstWindow();
win.open();
but still I am not able to get the device token I got an error
W/com.appcelerator.cloud.push.CCPushService: Getting GCM SenderId failed. No response area in returned JSON. Will try again in 5 seconds.
ALERT: (KrollRuntimeThread) [48763,48763] Failed to register for push notifications! Failed receiving GCM SenderId. Getting GCM SenderId failed. Max retry time reaches.
I am trying in Samsung galaxy grand,Android version:4.1.2 Do I need to make any changes or doing any wrong in my code.pls suggest me.

Viewing all articles
Browse latest Browse all 250

Latest Images

Trending Articles



Latest Images