2016-09-15 21 views
0

我有一臺帶有Ubuntu和Parse Server的虛擬機。解析服務器工作正常,但即時嘗試將其配置爲啓用推送通知。從WIKI解析,我知道我需要編輯JS擴展和寫一個配置文件:本地分析服務器推送配置

var server = new ParseServer({ 
    databaseURI: '...', 
    cloud: '...', 
    appId: '...', 
    masterKey: '...', 
    push: { 
    android: { 
     senderId: '...', 
     apiKey: '...' 
    }, 
    ios: { 
     pfx: '/file/path/to/XXX.p12', 
     bundleId: '', 
     production: false 
    } 
    } 
}); 

但問題是,我不知道哪裏是index.js文件。任何幫助表示讚賞。謝謝

解決方案: 謝謝,我解決了使用github的解析服務器示例編輯index.js文件並編輯雲目錄中的main.js文件。 在main.js現在有一個函數發送推送通知,我從Swift調用該函數。現在推送通知的作品! :)

+0

請看看解析服務器示例存儲庫在https://github.com/ParsePlatform/parse-server-example。它可能有幫助。 – courteouselk

+0

感謝您的回答。但是存儲庫示例的源代碼和路徑樹不同於沒有Express框架的獨立分析版本。 –

+0

新聞,可能我找到解決方案:以json格式啓動帶推參數和所有配置值的parse-server,今晚我會試試,我會更新我的答案。 –

回答

1

通常index.js文件在parse-server-example目錄中可用。

在index.js文件

var server = new ParseServer({ 
databaseURI: '...', 
cloud: '...', 
appId: '...', 
masterKey: '...', 
    push: { 
    android: { 
     senderId: '...', 
     apiKey: '...' 
     }, 
    ios: { 
     pfx: '/file/path/to/XXX.p12', 
     bundleId: '', 
     production: false //true for production 
    } 
    } 
}); 

添加或編輯下面的代碼後,你可以做以下捲曲請求來獲取用戶數據,這將返回所有用戶的信息: -

curl -X GET \ 
-H "X-Parse-Application-Id: YOUR_APP_ID" \ 
-H "X-Parse-Master-Key: YOUR_MASTER_KEY" \ http://localhost:1337/parse/installations 

要發送推送通知給用戶,您需要在curl請求下進行: -

curl -X POST \ 
-H "X-Parse-Application-Id: YOUR_APP_ID" \ 
-H "X-Parse-Master-Key: YOUR_MASTER_KEY" \ 
-H "Content-Type: application/json" \ 
-d '{ 
     "where": { 
     "deviceType": { 
     "$in": [ 
      "ios", 
      "android" 
     ] 
     }, 
     "deviceToken":"xxxxx" 
    }, 
     "data": { 
     "title": "Notification", 
     "alert": "Great Notification Message" 
     } 
    }'\ http://localhost:1337/parse/push