2016-07-19 2 views
0

IBM MFP 7.1에 각도로 작성된 iOS 하이브리드 응용 프로그램이 있습니다. 현재 푸시 알림을 사용하려고하지만 코드는 onReadyToSubscribe 메소드에 입력되지 않습니다.IBM MFP onReadyToSubscribe 메소드가 호출되지 않았습니다.

푸시 알림에 대한 설명서의 모든 코드를 얻었지만 여전히 문제가 있습니다.

내 응용 프로그램-descriptor.xml는

<application xmlns="http://www.worklight.com/application-descriptor" id="B" platformVersion="7.1.0.00.20151227-1725"> 
<displayName>A</displayName> 
<description>A</description> 
<author> 
    <name>application's author</name> 
    <email>application author's e-mail</email> 
    <homepage>http://mycompany.com</homepage> 
    <copyright>Copyright My Company</copyright> 
</author> 
<mainFile>index.html</mainFile> 
<features/> 
<thumbnailImage>common/images/thumbnail.png</thumbnailImage> 

<ipad bundleId="xxx.xxx.xxx" version="1.0" securityTest="PushSecurityTest" > 
    <worklightSettings include="false"/> 
    <pushSender password="123456"/> 
    <security> 
     <encryptWebResources enabled="false"/> 
     <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3"/> 
    </security> 
</ipad> 

main.js는 우리가해야 할 일을 파일입니다 마법

function wlCommonInit() { 

    PushAppRealmChallengeHandler.init(); 

    WL.Client.connect({ 
     onSuccess: connectSuccess, 
     onFailure: connectFailure 
    }); 

    //---------------------------- Set up push notifications ------------------------------- 
    if (WL.Client.Push) { 
     WL.Client.Push.onReadyToSubscribe = function() { 

      WL.SimpleDialog.show("Push Notifications", "onReadyToSubscribe", [ { 
       text : 'Close', 
       handler : function() {} 
       } 
       ]); 

      $('#SubscribeButton').removeAttr('disabled'); 
      $('#UnsubscribeButton').removeAttr('disabled'); 

      WL.Client.Push.registerEventSourceCallback(
       "myPush", 
       "PushAdapter", 
       "PushEventSource", 
       pushNotificationReceived); 
     }; 
    } 
} 

function connectSuccess() { 
    WL.Logger.debug ("Successfully connected to MobileFirst Server."); 
} 

function connectFailure() { 
    WL.Logger.debug ("Failed connecting to MobileFirst Server."); 
    WL.SimpleDialog.show("Push Notifications", "Failed connecting to MobileFirst Server. Try again later.", 
      [{ 
       text : 'Reload', 
       handler : WL.Client.reloadapp 
      }, 
      { 
       text: 'Close', 
       handler : function() {} 
      }] 
     ); 
} 
function loginButtonClicked() { 
    var reqURL = '/j_security_check'; 

    var options = { 
     parameters : { 
       j_username : $('#usernameInputField').val(), 
       j_password : $('#passwordInputField').val() 
     }, 
     headers: {} 
    }; 

    PushAppRealmChallengeHandler.submitLoginForm(reqURL, options, PushAppRealmChallengeHandler.submitLoginFormCallback); 
} 

function isPushSupported() { 
    var isSupported = false; 
    if (WL.Client.Push){ 
     isSupported = WL.Client.Push.isPushSupported(); 
    } 

    alert(isSupported); 
    WL.SimpleDialog.show("Push Notifications", JSON.stringify(isSupported), [ { 
     text : 'Close', 
     handler : function() {}} 
    ]); 
} 

function isPushSubscribed() { 
    var isSubscribed = false; 
    if (WL.Client.Push){ 
     isSubscribed = WL.Client.Push.isSubscribed('myPush'); 
    } 

    WL.SimpleDialog.show("Push Notifications", JSON.stringify(isSubscribed), [ { 
     text : 'Close', 
     handler : function() {}} 
    ]); 
} 

// --------------------------------- Subscribe ------------------------------------ 
function doSubscribe() { 
    WL.Client.Push.subscribe("myPush", { 
     onSuccess: doSubscribeSuccess, 
     onFailure: doSubscribeFailure 
    }); 
} 

function doSubscribeSuccess() { 
    WL.SimpleDialog.show("Push Notifications", "doSubscribeSuccess", [ { 
     text : 'Close', 
     handler : function() {}} 
    ]); 
} 

function doSubscribeFailure() { 
    WL.SimpleDialog.show("Push Notifications", "doSubscribeFailure", [ { 
     text : 'Close', 
     handler : function() {}} 
    ]); 
} 

//------------------------------- Unsubscribe --------------------------------------- 
function doUnsubscribe() { 
    WL.Client.Push.unsubscribe("myPush", { 
     onSuccess: doUnsubscribeSuccess, 
     onFailure: doUnsubscribeFailure 
    }); 
} 

function doUnsubscribeSuccess() { 
    WL.SimpleDialog.show("Push Notifications", "doUnsubscribeSuccess", [ { 
     text : 'Close', 
     handler : function() {}} 
    ]); 
} 

function doUnsubscribeFailure() { 
    WL.SimpleDialog.show("Push Notifications", "doUnsubscribeFailure", [ { 
     text : 'Close', 
     handler : function() {}} 
    ]); 
} 

//------------------------------- Handle received notification --------------------------------------- 
function pushNotificationReceived(props, payload) { 
    WL.SimpleDialog.show("Push Notifications", "Provider notification data: " + JSON.stringify(props), [ { 
     text : 'Close', 
     handler : function() { 
      WL.SimpleDialog.show("Push Notifications", "Application notification data: " + JSON.stringify(payload), [ { 
       text : 'Close', 
       handler : function() {}} 
      ]);  
     }} 
    ]); 
} 

그리고 마지막 마법의 js 파일은 인증을 처리 MFP 서버의 경우

var PushAppRealmChallengeHandler = (function(){ 

    var challengeHandler; 

    function init() { 
     challengeHandler = WL.Client.createChallengeHandler("PushAppRealm"); 
     challengeHandler.isCustomResponse = isCustomResponse; 
     challengeHandler.handleChallenge = handleChallenge; 
     challengeHandler.submitLoginFormCallback = submitLoginFormCallback; 
    } 

    function isCustomResponse(response) { 
     if (!response || response.responseText === null) { 
      return false; 
     } 
     var indicatorIdx = response.responseText.search('j_security_check'); 

     if (indicatorIdx >= 0){ 
      return true; 
     } 
     return false; 
    } 

    function handleChallenge(response) { 
     $('#AppBody').hide(); 
     $('#AuthBody').show(); 
     $('#passwordInputField').val(''); 
    } 

    function submitLoginFormCallback(response) { 
     var isLoginFormResponse = challengeHandler.isCustomResponse(response); 
     if (isLoginFormResponse){ 
      challengeHandler.handleChallenge(response); 
     } else { 
      $('#AppBody').show(); 
      $('#AuthBody').hide(); 
      challengeHandler.submitSuccess(); 
     } 
    } 

    function submitLoginForm(url, options, callback) { 
     challengeHandler.submitLoginForm(url, options, callback) 
    } 

    return { 
     init: init, 
     submitLoginForm: submitLoginForm, 
     submitLoginFormCallback: submitLoginFormCallback 
    } 
})(); 

인증서를 이미 확인 했으므로 인증서를 추가 할 때 모든 항목을 다시 배포합니다.

내가 문제가 될 수있는 아이디어가 있습니까? onReadyToSubscribe를 호출해야합니까? 응용 프로그램의 인증과 관련이 있습니까? 사전

+0

문제 오늘 보도되었습니다. 다음 링크를 참조하십시오. 1) http://stackoverflow.com/questions/38453587/apns-bug-since-today-didregisterforremotenotificationswithdevicetoken-not-gett 2) https://forums.developer.apple.com/message/155239 # 155239 3) https://forums.developer.apple.com/thread/52224 –

+0

다음 방법을 시도해보십시오. a) 프로덕션 인증서와 프로덕션 APN으로 테스트하십시오. b) 그래도 문제가 해결되지 않으면 다음 샘플에서 테스트 해보십시오. https://github.com/MobileFirst-Platform-Developer-Center/EventSourceNotifications/tree/release71 Eventsources로 테스트하는 특별한 이유가 있습니까? ? 향후 호환성을 위해 태그 기반 알림을 채택해야합니다. –

+0

Apple이 제기 한 문제에 대해 당신이 맞습니다. 오늘날 모든 것이 매력으로 작용합니다. 감사. – m1sh0

답변

관련 문제