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

时间:2017-03-06 08:58:35

标签: android cordova ibm-mobilefirst

我参加了Cordova项目示例并为Android环境添加了平台,然后我通过Google控制台创建了FCM项目,然后我获得了发件人ID和服务器密钥。我添加了MobileFirst服务器控制台凭据。完成上述步骤后,我在MobileFirst控制台“push.mobileclient”中添加了scope变量。最后,我尝试在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"

请帮助我解决问题。

1 个答案:

答案 0 :(得分:1)

在cordova项目中添加这些插件

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

尝试在Firebase Console中创建新项目并添加服务器密钥&仔细地在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));
        };
}

点击此处Not able to send push notification to iOS devices through MFP Server V8 Console