IBM MobileFirst Platform - 从适配器

时间:2017-03-28 08:09:22

标签: ios push-notification ibm-mobilefirst mobilefirst-adapters

我正在使用具有推送通知功能的IBM MobileFirst Platform 8.0开发iOS应用程序

我已经设法通过邮递员发送通知,过程是

  1. 从移动第一台平台服务器获取令牌
  2. 通过rest api发送通知以及令牌
  3. 我遵循的教程链接是,

    服务器端 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/

    客户端 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/cordova/

    获取令牌 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/confidential-clients/#obtaining-an-access-token

    目前,我正在尝试在应用触发适配器调用时发送推送通知

    我目前停留在使用WL.Server.invokeHttp获取令牌部分,下面是更多的适配器代码和连接设置

    function getToken() {
       var input = {
            method : 'post',
            returnedContentType : 'application/json',       
            path : '/mfp/api/az/v1/token',      
            headers : {
                Authorization:"Basic UHVzaE5asdasdas4444rrraWNhdGlvbjpQdXNoasdasd0aW9u",
                contentType:'application/x-www-form-urlencoded'
            },
            body:{
                grant_type : "client_credentials",
                scope : "push.application.my.app messages.write",
    
            }
    
        }; 
    
        var results =  MFP.Server.invokeHttp(input);
        return results;
    }
    
    <connectivity>
           <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
                <protocol>http</protocol>
                <domain>127.0.0.1</domain>
                <port>9080</port>
                <connectionTimeoutInMilliseconds>60000</connectionTimeoutInMilliseconds>
                <socketTimeoutInMilliseconds>60000</socketTimeoutInMilliseconds>
                <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
            </connectionPolicy>
        </connectivity>
    

    希望得到建议,提前谢谢。

1 个答案:

答案 0 :(得分:0)

我设法用这些代码解决它

var requestStructure = {
        method : 'post',
        returnedContentType : 'json',
        path : '/mfp/api/az/v1/token',      
        headers: {
            "Content-Type" : "application/x-www-form-urlencoded",
            "Authorization" : "Basic UHVzaE5asdasdas4444rrraWNhdGlvbjpQdXNoasdasd0aW9u"
        },
        parameters:{
            "grant_type" : "client_credentials",
            "scope" : "push.application.my.app messages.write"
        }
     };

    var results = MFP.Server.invokeHttp(requestStructure);
    return results;