2016-09-15 127 views
-1

我们正在使用mfp8.0开发离子应用程序。我们使用以下代码与mfp服务器连接,无法使用MFP8.0注册设备

var Messages = { 
    // Add here your messages for the default language. 
    // Generate a similar file with a language suffix containing the translated messages. 
    // key1 : message1, 
}; 

var wlInitOptions = { 
    // Options to initialize with the WL.Client object. 
    // For initialization options please refer to IBM MobileFirst Platform Foundation Knowledge Center. 
    onSuccess:function(){alert('success')}, 
    onFailure:function(){alert('fail')} 
}; 

function wlCommonInit() { 
    app.init(); 
} 

var app = { 
    //initialize app 
    "init": function init() { 
     app.testServerConnection(); 
    }, 
    //test server connection 
    "testServerConnection": function testServerConnection() { 
    WL.App.getServerUrl(function (url) { 
    }); 

    WLAuthorizationManager.obtainAccessToken() 
     .then(
     function (accessToken) { 
      alert('accessToken '+JSON.stringify(accessToken)); 
      isPushSupported(); 
     }, 
     function (error) { 
      alert('Error '+error); 
     } 
     ); 
    }, 

} 

function isPushSupported() { 
    MFPPush.isPushSupported(
     function(successResponse) { 
      alert("Push Supported: " + successResponse); 
      registerDevice(); 
     }, function(failureResponse) { 
      alert("Failed to get push support status"); 
     } 
    ); 
} 

function registerDevice() { 
    WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
     MFPPush.registerDevice(
      {"phoneNumber":""}, // workaround due to a defect in the current release of the product. An empty "phoneNumber" property must be passed at this time. 
      function(successResponse) { 
       alert("Successfully registered"); 
      }, 
      function(failureResponse) { 
       alert("Failed to register"); 
       alert("Failed to register device:" + JSON.stringify(failureResponse)); 
      } 
     ) 
    ); 
} 

我们可以通过mfp服务器进行连接。但是,我们无法注册推送通知设备。我们收到以下错误,

"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException:Response:Status=404, Text:Error 404: SRVE0295E: Error reported: 404\r\n, Error Message : Not Found" 

(或)

"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException:Response:Status=500,Text:{\"errorCode\":\"UNEXPECTED_ERROR\",\"errorMsg\":\"Unexpected Error Encountered\"}, Error Message : Unexpected Error Encountered" 

事实上,我们最近收到此错误。在此之前,相同的代码对我们来说工作得很好。

任何帮助将被赞赏!

回答

2

更改注册设备的相应功能。 请通过链接: https://github.com/MobileFirst-Platform-Developer-Center/PushNotificationsCordova/blob/release80/www/js/index.js

function registerDevice() { 
    WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
     MFPPush.registerDevice(
      null, 
      function(successResponse) { 
       alert("Successfully registered"); 
      }, 
      function(failureResponse) { 
       alert("Failed to register"); 
       alert("Failed to register device:" + JSON.stringify(failureResponse)); 
      } 
     ) 
    ); 
} 
0

你的代码片段没有表现出你是怎样尝试将应用程序注册到推送服务...

是否遵循推教程的指令,看着样品推送应用程序打开一个问题之前, ?

查看教程和样本,在这里:https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/

+0

它是从长回来工作。突然,它不工作。那就是我提出的这个问题。 –

+0

确保您使用的是更新后的SDK和服务器实例。使用最新的SDK,您不再需要phoneNumber解决方法 - 请参阅cordova教程以获取更新的API。 –