Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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 !

— asked April 1st 2010 by alexandre duquenoy
  • device
  • http
  • notifications
  • push
0 Comments

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;
         }
      }
    });
    
    — answered July 31st 2013 by Juan Carlos Salinas Ojeda
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.