0

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

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);  
}  

我从代码中收到警报消息“未定义推送通知”

4

1 回答 1

0

基于 Cordova 的 Oracle JET 没有开箱即用的推送通知,而是通常添加一个 3rd 方 Cordova 插件,例如https://github.com/phonegap/phonegap-plugin-push。我怀疑您遇到的错误表明您尚未添加 3rd 方插件。

您可以通过以下方式将其添加到您的 JET 项目中

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

b) 执行以下命令:

科尔多瓦插件添加 phonegap-plugin-push --variable SENDER_ID="XXXXXXXX"

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

该视频解释了在 JET 中使用 Oracle 移动云服务设置推送通知的完整步骤,与文章中的步骤一致,并应帮助您了解其工作原理:https ://youtu.be/6n-1 -bo2_iQ

于 2017-04-01T02:50:47.383 回答