javascript - PhoneGap 通知

标签 javascript cordova

我正在尝试使用 PhoneGap 制作一个非常简单的 Android/iPhone 应用程序。

即使应用没有在用户设备上运行,向应用发送推送通知的最简单方法是什么?

最佳答案

使用push notification phonegap插件:

onNotificationGCM: function(e) {
    switch (e.event) {
        case 'registered':
            if (e.regid.length > 0) {
                console.log("Regid " + e.regid);
                alert('registration id = ' + e.regid);
            }
            break;
        case 'message':
            // this is the actual push notification. its format depends on the data model from the push server
            alert('message = ' + e.message + ' msgcnt = ' + e.msgcnt);
            break;
        case 'error':
            alert('GCM error = ' + e.msg);
            break;
        default:
            alert('An unknown GCM event has occurred');
            break;
    }
}

完整的使用指南可以在这里找到:http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/

关于javascript - PhoneGap 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27524792/

相关文章:

ios - 在 Cordova/Ionic 中,如何在 native 应用程序中打开 Facebook 个人资料链接?

javascript - 使用 jquery ui map (gmap) 获取当前位置

javascript - clickHandler 或handleClick 或onClick 或signUp 或handleSignUp 或signUpHandler?

php - 如何通过像素和js检测将用户重定向到正确的网站模板?

javascript - 是否可以使用闭包来模拟 Javascript 中的常量?

angular - 找不到模块 "ionic-native"

javascript - 检查表 tr td 是否不为空

javascript - `new Array(n)` 和 `Array(n)` 有什么区别

visual-studio - 无法在 vs 2017 中调试问题 Apache cordova 项目

ios - inappbrowser 在 iOS 上无法正常工作