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

Push: Change from MQTT to GCM?

$
0
0

How can I change from MQTT to GCM in my project?

08-19 12:54:13.999: I/com.appcelerator.cloud.push.PushService(5040): Creating PushService.
08-19 12:54:13.999: I/com.appcelerator.cloud.push.PushService(5040): Handling crashed service...
08-19 12:54:14.009: I/com.appcelerator.cloud.push.PushService(5040): Starting push service...
08-19 12:54:14.009: I/com.appcelerator.cloud.push.PushService(5040): PushService status changed. ACTION=CF.KEEP_ALIVE
08-19 12:54:14.009: I/com.appcelerator.cloud.push.PushService(5040): PushService status changed. ACTION=CF.KEEP_ALIVE
08-19 12:54:14.009: I/com.appcelerator.cloud.push.PushService(5040): PushService status changed. ACTION=CF.KEEP_ALIVE
08-19 12:54:14.159: D/com.appcelerator.cloud.push.PushService(5040): Connectivity changed. Network availability:true; Has connectivity:true; type:WIFI; reason:null
08-19 12:54:14.159: D/com.appcelerator.cloud.push.PushService(5040): MQTT Status:NULL
08-19 12:54:14.159: I/com.appcelerator.cloud.push.PushService(5040): Reconnecting...
08-19 12:54:14.169: D/com.appcelerator.cloud.push.PushService(5040): Push Host: push-1.cloud.appcelerator.com, Push Port: 1883
08-19 12:54:14.870: I/com.appcelerator.cloud.push.PushService(5040): MQTT Connected
I'm using SDK 3.1.2 and have set my tiapp.xml to:
<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>
If I'm checking the properties I'll get:
alert(Ti.App.Properties.getString("acs-push-type-production"));
alert(Ti.App.Properties.getString("acs-push-type-development"));
alert(Ti.App.Properties.getString("acs-push-type"));
and inside the cloud subscribed devices list I have:
channel  android(mqtt)  id token

my code:

var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
 
CloudPush.addEventListener('trayClickLaunchedApp', function(evt) {
            pushReceived();
});
CloudPush.addEventListener('trayClickFocusedApp', function(evt) {
            pushReceived();
});
CloudPush.addEventListener('callback', function(evt) {
            Ti.API.info("cloud - push callback");
            pushReceived();
});
 
// [register cloud user] function removed
 
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
 
// [login user] function removed
 
CloudPush.retrieveDeviceToken({
    success : function deviceTokenSuccess(e) {
        deviceToken = e.deviceToken;
subscribe();
 
    }, error : function deviceTokenError(e) {
        Ti.API.info("PUSH ERROR");
    }
});
to shorten the code I removed the register and login functions (Cloud.Users.create/login)

Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>