【问题标题】:Local Parse Server Push Configuration本地解析服务器推送配置
【发布时间】:2016-09-15 08:53:48
【问题描述】:

我有一个带有 Ubuntu 和 Parse Server 的虚拟机。 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 调用该函数。现在推送通知有效! :)

【问题讨论】:

  • 请查看github.com/ParsePlatform/parse-server-example 的解析服务器示例存储库。这可能会有所帮助。
  • 感谢您的回答。但是存储库示例的源代码和路径树与没有 Express Framework 的独立解析版本不同。
  • 新闻,可能我找到了解决方案:使用push参数和json格式的所有配置值启动解析服务器,今晚我会尝试更新我的答案。

标签: javascript 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 请求来获取用户数据,这将返回所有用户的信息:-

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 1970-01-01
    相关资源
    最近更新 更多