2016-09-15 4 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. Но мы не можем зарегистрировать устройство для push notifcations. Мы получаем следующее сообщение об ошибке,

"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 - см. Учебник по кордове для обновленного API. –

Смежные вопросы