繁体   English   中英

Mobilefirst 8.0 Cordova推送通知设备注册失败

[英]Mobilefirst 8.0 cordova push notification device register failed

我拿了示例Cordova项目并为Android环境添加了平台,然后通过Google控制台创建了FCM项目,然后获得了发件人ID和服务器密钥。 我添加了MobileFirst服务器控制台凭据。 完成上述步骤后,我将范围变量添加到MobileFirst控制台“ push.mobileclient”中。 最后,我尝试在Android模拟器上使用Android Studio运行项目。

单击注册设备时,推送通知的测试失败。 下面是错误日志:

无法注册 device:"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException: Response: Status=400, Text: {\\"errorCode\\":\\"invalid_client\\",\\"errorMsg\\":\\"Incorrect JWT format\\"}, Error Message: Incorrect JWT format"

请帮助我解决问题。

将这些插件添加到cordova项目中

cordova plugin add cordova-plugin-mfp
cordova plugin add cordova-plugin-mfp-push

尝试在Firebase控制台中创建新项目,并在Mobilefirst控制台中仔细添加服务器密钥发件人ID

在真实设备上运行。 在移动设备和计算机上也要使用相同的网络(wifi)。

您可以在MobileFirst控制台中尝试不使用范围变量“ push.mobileclient”,然后尝试示例代码:

样例代码

    function wlCommonInit(){

   //initialize app for push notification
        MFPPush.initialize (
            function(successResponse) {
                alert("Push Notification Successfully intialized");
                MFPPush.registerNotificationsCallback(notificationReceived);
            },
            function(failureResponse) {
                alert("Failed to initialize");
            }
        );

        //Check device is Supported for push notification
        MFPPush.isPushSupported (
            function(successResponse) {
                alert("Device is Push Supported");
            },
            function(failureResponse) {
                alert("Failed to get push support status");
            }
        );

        //register app for push notification
        MFPPush.registerDevice( null,
            function(successResponse) {
                    alert("Device Successfully registered");
            },
            function(failureResponse) {
                alert("Failed to register");
            }
        );

        var notificationReceived = function(message) {
            alert(JSON.stringify(message));
        };
}

检查此处无法通过MFP Server V8控制台将推送通知发送到iOS设备

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM