HTTP Request and push notifications
Hello,
I have a question about the possibility with Titanium to get and then send via HTTP protocol the following values :
Device Model, Display Name, Unique ID, Token & Version Number.
Perhaps there's a way to do that in :
Titanium.Network.registerForPushNotifications
but there's no such things in the documentation.
Thanks !
1 Answer
-
Ti.Network.registerForPushNotifications({ types: [ Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND ], success:function(e){ var deviceToken = e.deviceToken; grabar_opcion( "deviceToken", deviceToken ) enlace = "http://tudireccion/archivo.php?task=register&appname="+Titanium.App.name+"&appversion="+Titanium.App.version+"&deviceuid="+obtener_id()+"&"; enlace = enlace + "devicetoken="+deviceToken+"&devicename="+Titanium.Platform.name+"&devicemodel="+Titanium.Platform.model+"&"; enlace = enlace + "deviceversion="+Titanium.Platform.version+"&pushbadge=enabled&pushalert=enabled&pushsound=enabled"; var peticionHTTP = Ti.Network.createHTTPClient(); peticionHTTP.onerror = function() { Alerta.message = "No se pudo registrar su dispositivo para notificaciones PUSH"; Alerta.show(); return false; } peticionHTTP.onload = function() { Ti.API.info("*** Todo ok"); }; peticionHTTP.open("GET", enlace ); peticionHTTP.send(); }, error:function(e) { Ti.API.info("*** ERROR: " + e.error ); Alerta.message = e.error ; Alerta.show(); }, callback:function(e) { Ti.API.info("*** Regresamos a la APP "); // Titanium.UI.iPhone.appBadge ++; // itemHistoria.badge = Titanium.UI.iPhone.appBadge; switch( e.data.tipo_push ) { case "CHAT": Ti.API.info("*** Tipo Chat"); break; case "OTRO": Ti.API.info("*** Tipo otro"); break; } } });