User Tools

Site Tools


spes:node_acs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
spes:node_acs [2014/09/24 09:01] – aggiunti link lettispes:node_acs [2014/10/28 11:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-**Risultato atteso:** inviare notifiche PUSH da un server verso altri server, in maniera asincrona (tramite un canale). Questi server si preoccuperanno poi di inoltrare le notifiche verso altri dispositivi.+=====GUIDA PER LE PUSH=====
  
-**Teconologie:** Node.js, Appcelerator Node.ACS 
  
-**Referenze:**+===Risultato atteso:=== 
  
-Node.ACS quickstart: http://docs.appcelerator.com/cloud/latest/#!/guide/node_quickstart  +Inviare notifiche PUSH da un server verso altri device registrati al servizioÈ richiesto che la notifica arrivi anche se il ricevente non è UP.
-Node.ACS MVC Framework: http://docs.appcelerator.com/cloud/latest/#!/guide/node_mvc +
-Node.ACS CLI command reference: http://docs.appcelerator.com/cloud/latest/#!/guide/node_cli +
-Google Developing Console (API Key): https://console.developers.google.com/project+
  
-**Installazione**+===Teconologie:===
  
-In questa sezione vengono registrati i passi svolti seguendo il QuickStart di Node.ACS ( http://docs.appcelerator.com/cloud/latest/#!/guide/node_quickstart )  al fine di ottenere un'applicazione utilizzando  l'MVC framework contenuto in Node.ACS+Appcelerator ACS, cURL
  
-- installare **Node.js** e **npm** +===Referenze:===
  
-* installare Node.js dal sito http://nodejs.org/ (nota: Node.ACS CLI richiede Node versione 0.8.13 o sueriore ) 
  
-npm è installato automaticamente con Node dalla versione 0.6.Nel caso fosse necesario installarlo, scaricarlo dall'npm github repo https://github.com/isaacs/npm/ .+  Google Developing Console: https://console.developers.google.com/project 
 +  * http://www.titaniumtutorial.com/2013/10/acs-push-notification-using-gcm.html 
 +  * http://docs.appcelerator.com/cloud/latest/#!/api/PushNotifications-method-subscribe
  
-- installare la Node.ACS CLI, **acs**+====Settare l'environnement====
  
-* npm install -g acs+E’ necessario installare cURL: [http://curl.haxx.se/dev/source.html]
  
-**Creare una app 
  
-- Login +> NOTA: in questo documento viene mostrato come inviare notifiche ad un device Android. Tuttavia il processo è parallelo per device IOS, con i dovuti accorgimenti riportati nei link alla documentazione di Appcelerator presenti nelle prossime sezioni.  
  
-Autenticazione all'ACS cloud: 
  
-acs login+====Azioni preventive====
  
-**richiede un account Appcelerator** 
  
-- Creare applicazione:+===Configurare il servizio di push per Android===
  
-acs new nome_app 
  
-Di default, l'applicazione è configurata per usare il Node.ACS MVC framework.+  * Questa parte è volta all’utilizzo di GCM (Google Cloud Messaging) per implementare un servizio di Push Notifications verso device Android utilizzando ACS (Appcelerator Cloud Services): 
 +  * Creare un progetto nella Google Cloud Console [https://cloud.google.com/console]. In questo modo sarà possibile ottenere: 
 +    * l’ID del progetto (nellla schermata di riepilogo dello stesso) 
 +    * una API KEY, ottenuata creando una Server Key nella sezione “APIs & Auth” 
 +  * Creare un’ACS app nell’ Appcelerator cloud console [https://my.appcelerator.com/apps]. Questa azione servirà per ottenere una APP KEY da utilizzare nel momento in cui le Push Notifications verranno inviate dal server ai device registrati. Inoltre, sarà necessario inserire la API KEY e il Project Number nella sezione “Android Push Configuration” in “Manage ACS” della App.
  
-- Pubblicare la app nel cloud: 
  
-cd nome_app +===Configurare il servizio di push per IOS===
-acs publish+
  
 +  * Questa parte è volta all’utilizzo di APN (Apple Push Notifications ] per implementare un servizio di Push Notifications verso device IOs utilizzando ACS.
 +  * Non testato, ma c’è una guida esaustiva su: [http://docs.appcelerator.com/titanium/3.0/#!/guide/Configuring_push_services-section-37551713_Configuringpushservices-ConfiguringpushservicesforiOSdevices]
  
-**Links:** 
  
-* http://www.titaniumtutorial.com/2013/10/acs-push-notification-using-gcm.html +====INVIARE PUSH NOTIFICATIONS====
-* http://docs.appcelerator.com/cloud/latest/#!/api/PushNotifications-method-subscribe+
  
 +In [http://docs.appcelerator.com/cloud/latest/#!/api/PushNotifications] è possibile trovare una lista dei possibili parametri da passare a una Push
 +
 +> **Importante:** ACS richiede necessariamente un’autenticazione prima di procedere a una push. 
 +
 +> **NOTA:** controllare se l’autenticazione è effettivamente fatta tramite i cookie, e non sia a livello di sessione
 +
 +
 +Il device deve essere precedentemente registrato.
 +
 +> **NOTA:** a meno di controlli, è possibile per un utente registrarsi diverse volte con lo stesso utente ma diversi devices
 +
 +
 +===SINTASSI===
 +
 +curl -b cookies.txt -c cookies.txt [ [-F “param=value”] ] https://api.cloud.appcelerator.com/v1/users/login.json?key=<APP KEY>
 +
 +
 +===AUTENTICAZIONE:===
 +
 +==req==
 + 
 +curl -b cookies.txt -c cookies.txt -F"login=prova" -F "password=prova" https://api.cloud.appcelerator.com/v1/users/login.json?key=bMDOIoxIVfncwv1Vn9RZf9xP4n3qvGiW
 +
 +==resp== 
 +
 +<code>
 +{
 +    "meta":{
 +        "code":200,
 +        "status":"ok",
 +        "method_name":"loginUser",
 +        "session_id":"VbX9Gc6pyb_M1NjAqbDcJjb4XcU"
 +    },
 +    "response":{
 +        "users":[
 +            {
 +                "id":"542338525b6e9117710007ea",
 +                "first_name":"prova",
 +                "last_name":"prova",
 +                "created_at":"2014-09-24T21:32:02+0000",
 +                "updated_at":"2014-09-25T11:37:36+0000",
 +            "external_accounts":[],
 +                "confirmed_at":"2014-09-24T21:32:02+0000",
 +                "username":"prova",
 +                "role":"prova",
 +                "admin":"false",
 +            "stats":{
 +                "photos":{
 +                    "total_count":0
 +                },
 +                "storage":{
 +                "used":0
 +                }
 +             },
 +            "email":"c@c.it",
 +            "friend_counts":{
 +                "requests":0,
 +                "friends":0
 +            }
 +        }
 +        ]
 +    }
 +}
 +</code>
 +
 +==Parametri:==
 +
 +“login=” richiede il nome utente
 +“password=” richiede la password
 +“key=” richiede l’APP KEY della ACS APP sul cloud appcelerator
 +
 +
 +===PUSH:===
 +
 +==req:== 
 +curl -b cookies.txt -c cookies.txt -F  "channel=alert2" -F "to_ids=542338525b6e9117710007ea" -F "payload=nuovo_messaggio" https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=bMDOIoxIVfncwv1Vn9RZf9xP4n3qvGiW
 +
 +==resp:==
 +
 +<code>
 +{
 +    "meta":{
 +        "code":200,
 +        "status":"ok",
 +        "method_name":"Notify"
 +    },
 +    "response":{
 +        "push_notification":{
 +            "id":"5423ff889ece8cdec5004e64",
 +            "payload":"nuovo_messaggio",
 +            "channel":"alert2"
 +        }
 +    }
 +}
 +</code>
 +
 +==parametri:==
 +
 +“channel=” è il canale su cui viene pushata la notifica
 +“to_ids=” contiene una lista di id relativi ai device iscritti al canale
 +“payload=” contiene il testo della notifica
 +“key=” richiede l’APP KEY della ACS APP sul cloud appcelerator
 +
 +> **NOTA:** altre proprietà possono essere settate, come i Badges. Inoltre ci sono alcune proprietà settabili solo per device Android.
 +
 +> **NOTA:** il parametro payload puo essere settato in due diversi modi, come stringa o come Json:
 +
 +> payload : String/Hash required
 +> Payload to send with the push notification.
 +> For a string, it will be sent as an alert (message notification).
 +> For a JSON payload, you can specify the following fields as well as custom fields:
 +> alert (String): Notification message to be displayed.
 +> badge (String): Number to set as the badge on the application's icon. Specify postive and negative numbers with the + and - symbols to increment or decrement the current badge number, respectively.
 +> sound (String): Filename minus the extension of the sound to play.
 +> For native Android applications, place the file in the /assets/sound directory.
 +> For native iOS applications, place the file in the main bundle.
 +> For Android applications built with Titanium, place the file in the /Resources/sound directory.
 +> For iOS applications built with Titanium, place the file in the /Resources directory.
 +> icon (String): Available on Android only. Filename minus the extension of the icon to display in the notification center. Place the file in /res/drawable for native Android applications or /Resources for Titanium applications. Uses the app's icon by default.
 +> title (String): Available on Android only. Title of the notification.
 +> vibrate (Boolean): Available on Android only. If true, the device vibrates for one second.
 +> For example:
 +> {
 +>     "atras": "your_user_id",
 +>     "tags": [
 +>         "tag1",
 +>         "tag2"
 +>     ],
 +>     "badge": "+2",
 +>     "sound": "default",
 +>     "alert" : "Push Notification Test"
 +> }
 +> In the above example, the atras and tags keys are custom fields, "badge" : "+2" increments the current badge value by two, "sound" : "default" plays a default system sound and "alert" : "Push Notification Test" pops up a alert window with text "Push Notification Test".
 +
 +
 +> **DA VERIFICARE:** come si fa a far ricevere la notifica a un server che non sia un device ??
 +
 +
 +====PER DEPLOYARE UN’APPLICAZIONE CHE POSSA REGISTRARSI SULL’ACS====
 +
 +E’ necessario Titanium CLI.
 +
 +===Prerequisiti:===
 +
 +Installare le oracle JDK (da 6 a 8 )
 +Installare Node.js
 +Installare Android SDK (per la versione, vedere http://docs.appcelerator.com/titanium/3.0/#!/guide/Installing_the_Android_SDK
 +Installare Android NDK  > 9 (per la vesrione non rischiesto) http://docs.appcelerator.com/titanium/3.0/#!/guide/Installing_the_Android_NDK
 +
 +===Installare la CLI con il comando npm===
 +
 +npm install -g titanium
 +
 +===Fare il login tramite npm===
 +
 +titanium login
 +
 +===Installare le SDK===
 +
 +titanium sdk install
 +
 +===Configurare===
 +
 +titanium setup quick , oppure
 +titanium setup (avanzato)
 +
 +
 +===SVILUPPO SU DEVICE===
 +
 +I device Android riceventi devono usare il pacchetto ti.cloudpush per registrarsi all’ACS sotto una applicazione ACS. In seguito ricevereanno le push notifications inviate loro sui canali corrispondenti.
 +
 +I device IOS riceventi devono usare il pacchetto ti.cloud per registrarsi all’ACS sotto una applicazione ACS. In seguito ricevereanno le push notifications inviate loro sui canali corrispondenti.
  
  
  
spes/node_acs.1411549303.txt.gz · Last modified: 2014/10/28 11:28 (external edit)