无法在Oracle JET中注册推送通知

时间:2017-03-31 12:41:37

标签: oracle-jet mcs

我按照以下链接中给出的步骤进行操作。

https://community.oracle.com/community/cloud_computing/oracle-cloud-developer-solutions/blog/2016/08/16/your-first-push-notification-based-oracle-jet-hybrid-application

但我无法在登录时注册推送通知。

function registerDeviceForMCSPush(mcsBackend) {  
    var defer = $.Deferred();  
    if (typeof PushNotification !== 'undefined') {  
        try {  
            var push = PushNotification.init({  
                "android": {  
                    // TODO replace Google Project Number here  
                    senderID: "55926"
                }  
            });  
            push.on('registration', function (data) {  
                var regId = data.registrationId;  
                deviceHandshakeforCordova(mcsBackend, regId);  
            });  
            push.on('notification', function (data) {  
                alert("Push Notification from Oracle MCS: " + data.message);  
            });  
            push.on('error', function (e) {  
                alert("Push Notification Error=" + e.message);  
            });  
        } catch (ex) {  
            alert("Error registering device with MCS" + ex);  
            defer.reject();  
        }  
    } else {  
        alert("PushNotification NOT Defined!");  
        defer.reject();  
    }  
    return $.when(defer);  
}  

我收到提醒信息"未定义推送通知"来自代码

1 个答案:

答案 0 :(得分:0)

基于Cordova的Oracle JET没有开箱即用的推送通知,而是添加第三方Cordova插件(例如https://github.com/phonegap/phonegap-plugin-push)的典型情况。我怀疑你收到的错误表明你还没有添加第三方插件。

您可以通过

将其添加到JET项目中

a)cd进入您的应用程序目录,然后进入混合目录

b)执行以下命令:

cordova插件添加phonegap-plugin-push --variable SENDER_ID =" XXXXXXXX"

... XXXXXXX映射到Firebase开发人员控制台中的项目编号。

此视频介绍了使用Oracle Mobile Cloud Service在JET中设置推送通知的完整步骤,并与本文中的步骤一致,并应为您提供协助,帮助您了解其工作原理:https://youtu.be/6n-1-bo2_iQ