//Called when application is started. function OnStart() { //Start our service. svc = app.CreateService( "this","this", ()={ // On service ready console.log( "Service Ready" ); }); svc.SetOnMessage( OnServiceMessage ); //This will cause your service to start at boot. //(Set it to "none" if you need to stop it starting) app.SetAutoBoot( "Service" ); var id = app.GetNotifyId(); if( id ) HandleNotification(id); } //Called when application is resumed. //(eg. When user returns from home screen) // or after notification is clickeed while app was open function OnResume() { app.ShowPopup( "On resume!", "Short" ); var id = app.GetNotifyId(); if( id ) HandleNotification(id); } function HandleNotification(id) { app.CreateNotification().Cancel(id) app.Alert( id, "Notification ID" ); } //Called when messages comes from our service. function OnServiceMessage( msg ) { console.log( "Service Message: " + msg ); }