2014-07-17 50 views
0

我創建一個Web應用程序並使用Parse來管理用戶,我使用我的Parse applicationID和JavaScriptId。解析Web應用程序憑據並將推送到不同的憑據

Parse.initialize("my-app-id", "my-js-id"); 
Parse.User.logIn(username, password,... 

當用戶登錄該網站時,他/她輸入自己的解析應用ID和JS-ID屬於自己的移動應用程序,他們要推一個通知。和網站發送通知給他們:

Parse.initialize("their-android-app-id", "their-android-js-id"); 
Parse.Push.send({ where: new Parse.Query(Parse.Installation), data: ... 

我不清楚何時調用初始化和我我的JavaScript的應用程序和Android/iOS的應用程序,我要發送到怎麼區分。

回答

1

只要我知道它是不可能與兩個不同的api鍵使用相同的api。我認爲這將是對應用程序A使用普通JavaScript-API的最簡單方法,但是對於應用程序B使用REST-API,因爲您只需發送推送通知給應用程序B.

在JQuery中,找例子是這樣的:

$.ajax({ 
    url: 'https://api.parse.com/1/push', 
    type: 'post', 
    data: { 
     where : { 
      ... 
     }, 
     data : { 
      ... 
     } 
    }, 
    headers: { 
     "X-Parse-Application-Id": "their-app-id", 
     "X-Parse-REST-API-Key": "their-rest-api-key", 
    }, 
    contentType: 'application/json', 
    dataType: 'json', 
    success: function (data) { 
     //data: response data from the Parse.com REST-API 
    } 
}); 

從解析quide有關如何通過REST的API使用推送通知,請here.

相關問題