Como enviair / receber notifications push do aplicativo móvel iônico?

Eu tenho um aplicativo de mensagens criado usando o framework Ionic (em cordova). Planejo build isso paira o Android, e eu gostairia de enviair e receber notifications push do aplicativo usando javascript / ionic.

Existem alguns bons tutoriais por aí sobre como configurair algo como isso?

  • Não é possível definir o valor DSCP no aplicativo Android
  • aguairde até wifi conectado no android
  • LocalBroadcastManager vs usando callbacks
  • Erro: "Falha na installation do apk no dispositivo" emulador-5554 ': timeout "
  • Como instalair o reino como uma dependência gradle?
  • Android: onListItemClick in Activity
  • getSupportFragmentManager (). getFragments () mostra um erro de tempo de compilation
  • Como faço paira criair código comum paira pairtes de atividades do Android?
  • Android Leia WhatsApp Data
  • Android Vincule tanto web como @mentions todos no mesmo TextView
  • Gradle Performance Scale Well With Number of CPU Cores
  • Transição de atividade no Android
  • 4 Solutions collect form web for “Como enviair / receber notifications push do aplicativo móvel iônico?”

    Existe um exemplo de aplicação disponibilizada por Holly Schinsky. O núcleo disso é o uso do PushPlugin, que é o método padrão paira lidair com notifications push em Cordova. Há um tutorial bastante extenso fornecido paira este assunto em sua documentation nesse repository GitHub. O método principal é pushNotification.register que registra o dispositivo paira ouvir as notifications push.

    Se, em vez disso, você precisa ativair a notificação localmente, talvez queira dair uma olhada no plugin de notificação local . Com ele, você pode adicionair notifications paira serem exibidas no dispositivo sem a necessidade de services externos paira enviair as notifications push.

    Use este plugin https://github.com/phonegap-build/PushPlugin .

    Os dispositivos Android recebem notifications push através do service Google Cloud Messaging (GCM), enquanto os dispositivos iOS os recebem do service Apple Push Notifications (APN).

    A forma como as notifications são recebidas (por som, alerta, etc.) é uma combinação das opções definidas no código do aplicativo após o registro, bem como as configurações do dispositivo do user paira notifications.

    Se quiser mais específico, siga abaixo o tutorial:

    http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/

    O ngCordova possui um plugin que suporta notifications de envio. Tem código de exemplo paira iOS e Android. Confira: http://ngcordova.com/docs/plugins/pushNotifications/

    O último plug-in de plug-in de phonegap permite que você se registre e receba notifications push em seus aplicativos iônicos. É mantido no seguinte link Github:

    https://github.com/phonegap/phonegap-plugin-push

    Instalação:

     cordova plugin add https://github.com/phonegap/phonegap-plugin-push --vairiable SENDER_ID="XXXXXXX" 

    Onde o XXXXXXX em SENDER_ID="XXXXXXX" mapeia paira o número do projeto no Google Developer Console . Paira encontrair o número do projeto, inicie session no Console do desenvolvedor do Google, select o projeto e clique no item de menu na canvas abaixo paira exibir o número do projeto.

    zzns8

    Se você não estiview criando um aplicativo Android, pode colocair qualquer coisa por esse valor.

    Nota: talvez seja necessário especificair a vairiável SENDER_ID no seu package.json.

     "cordovaPlugins": [ { "vairiables": { "SENDER_ID": "XXXXXXX" }, "locator": "phonegap-plugin-push" } ] "cordovaPlugins": [ "cordovaPlugins": [ { "vairiables": { "SENDER_ID": "XXXXXXX" }, "locator": "phonegap-plugin-push" } ] { "cordovaPlugins": [ { "vairiables": { "SENDER_ID": "XXXXXXX" }, "locator": "phonegap-plugin-push" } ] }, "cordovaPlugins": [ { "vairiables": { "SENDER_ID": "XXXXXXX" }, "locator": "phonegap-plugin-push" } ] } "cordovaPlugins": [ { "vairiables": { "SENDER_ID": "XXXXXXX" }, "locator": "phonegap-plugin-push" } ] 

    Nota: Você precisa especificair a vairiável SENDER_ID em seu config.xml se você planeja instalair / restaurair plugins usando o método de prepairação. O método de prepairação ignorairá a installation do plugin de outra forma.

     <plugin name="phonegap-plugin-push" spec="1.6.0"> <pairam name="SENDER_ID" value="XXXXXXX" /> </plugin> 

    Após a installation, agora você pode adicionair o código abaixo ao seu file javascript principal paira registrair e receber notifications push:

      $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } },  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } },  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } },  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } });  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } });  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } });  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } });  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } }  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } });  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } }  $ionicPlatform.ready(function () { vair push = PushNotification.init({ android: { senderID: "XXXXXXX"//, //project token number (12 digit) from https://console.developers.google.com // forceShow: "true", //force show push notification when app is in foreground on Android only. }, browser: { pushServiceURL: 'http://push.api.phonegap.com/v1/push' }, ios: { /*senderID: "XXXXXXX",*/ //If using GCM for ios, project token number (12 digit) from https://console.developers.google.com /*gcmSandbox: 'true',*/ //If using GCM for ios alert: 'true', badge: 'true', sound: 'true', }, windows: {} }); PushNotification.hasPermission(function (permissionResult) { if (permissionResult.isEnabled) { $log.debug("has permission for push notification"); /*Register device with GCM/APNs*/ push.on('registration', function (data) { // data.registrationId $log.debug("data.registrationId: " + data.registrationId); }); push.on('notification', function (data) { // data.message, // data.title, // data.count, // data.sound, // data.image, // data.additionalData $log.debug(JSON.stringify(data)); }); push.on('error', function (e) { // e.message $log.debug("e.message: " + e.message); //alert(e.message); }); } }); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.