2016-09-15 62 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