Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 本地解析服务器推送配置_Javascript_Parse Server - Fatal编程技术网

Javascript 本地解析服务器推送配置

Javascript 本地解析服务器推送配置,javascript,parse-server,Javascript,Parse Server,我有一个带有Ubuntu和解析服务器的虚拟机。解析服务器运行良好,但我正在尝试将其配置为启用推送通知。通过WIKI解析,我知道我需要编辑一个扩展名为JS的配置文件,并编写: var server = new ParseServer({ databaseURI: '...', cloud: '...', appId: '...', masterKey: '...', push: { android: { senderId: '...', apiK

我有一个带有Ubuntu和解析服务器的虚拟机。解析服务器运行良好,但我正在尝试将其配置为启用推送通知。通过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中的parse server示例解决了在cloud目录中编辑index.js文件和编辑main.js文件的问题。
现在在main.js中有一个发送推送通知的函数,我从Swift调用该函数。现在推送通知可以工作了!:)

通常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 -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

通常,index.js文件位于parse server示例目录中

在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 -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

请查看位于的解析服务器示例存储库。也许会有帮助。谢谢你的回答。但是存储库示例的源代码和路径树与没有Express Framework.news的独立解析版本不同,我可能找到了解决方案:使用push参数和json格式的所有配置值启动解析服务器,今晚我将尝试并更新我的答案。请查看位于的解析服务器示例存储库。也许会有帮助。谢谢你的回答。但是存储库示例的源代码和路径树不同于没有Express Framework的独立解析版本。新闻,可能我找到了解决方案:使用push参数和json格式的所有配置值启动解析服务器,今晚我将尝试并更新我的答案。