ios - IBM Mobile First Platform - Sending Push Notification from adapter -
i developing ios app using ibm mobilefirst platform 8.0 sdk have push notification capabilities
i managed send notification via postman, process obtaining token mobilefirst platform server , send notification via rest api along token
the tutorial link have follow is,
server side - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/
client side - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/cordova/
for now, trying send push notification when app triggers adapter call
i stuck on sending notification using wl.server.invokehttp, below more adapter code
function sendpushnotification(message) {         var result = gettoken();         var access_token = "bearer " + result["access_token"];          var requeststructure = {         method : 'post',         returnedcontenttype : 'json',         path : '/imfpush/v1/apps/my.app/messages',         headers: {             "content-type" : "application/json",             "authorization" : access_token         },           parameters : {           'message':{'alert' : 'test message'}         }     };      result = mfp.server.invokehttp(requeststructure);      return result; }   function gettoken() {    var requeststructure = {         method : 'post',         returnedcontenttype : 'json',         path : '/mfp/api/az/v1/token',               headers: {             "content-type" : "application/x-www-form-urlencoded",             "authorization" : "basic uhvzae5vd213123asdsadglvbjpqdxnotm90aasdasdwzpy2f0aw9u"         },         parameters:{             "grant_type" : "client_credentials",             "scope" : "push.application.my.app messages.write"         }     };      var results = mfp.server.invokehttp(requeststructure);     return results; } i seems having issue on
parameters : {     'message':{'alert' : 'test message'} } i might have done wrongly on part, hope advice.
thanks in advance
the sendpushnotification method use wrong syntax calling ws in mobile first. cloud change this:
function sendpushnotification(message) {     var result = gettoken();     var access_token = "bearer " + result["access_token"];      var requeststructure = {     method : 'post',     returnedcontenttype : 'json',     path : '/imfpush/v1/apps/my.app/messages',     headers: {         "authorization" : access_token     },      body: {         content: 'message':{'alert' : 'test message'},         contenttype: 'application/json'     } };  result = mfp.server.invokehttp(requeststructure);  return result; }
Comments
Post a Comment