簡體   English   中英

發送推送通知的難度(解析服務器/ Heroku)

[英]Difficulties sending push-notifications (Parse-Server/Heroku)

我無法從我的(目標C,iOS)應用中發送推送通知。

由於這是我第一次在這種環境中進行此操作,因此我可能缺少一些重要的細節。

這是index.js中用於ParseServer初始化的代碼的形狀:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://heroku_xyz336:.....mlab.com:.../heroku_xyz336',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppID',
  masterKey: process.env.MASTER_KEY || 'myMasterKey',
  push: {
      ios: [
        {
          pfx: '/cloud/MY_APP.Dev.p12',
          bundleId: 'me.you.bundleId',
          production: false // Dev
        },
        {
          pfx: '/cloud/MY_APP.Prod.p12',
          bundleId: 'me.you.bundleId',  
          production: true // Prod
        }
      ]
  },
  fileKey: process.env.FILE_KEY || 'myFileKey',
  serverURL: process.env.SERVER_URL || 'https://myApp.herokuapp.com/parse',
  liveQuery: {
    classNames: ["ClassOne", "ClassTwo", "ClassThree"] // List of classes to support for query subscriptions
  }
});

這是我在日志中得到的:

app[web.1]: Now inside function pushing Notifications.
 app[web.1]: info: beforeSave triggered for MyApp for user Yacb7KxgA9:
 app[web.1]:   Input: {"....}
 app[web.1]:   Result: {"object":{"....}} className=MyApp, triggerType=beforeSave, user=Yacb7KxgA9
 heroku[router]: at=info method=POST path="/parse/classes/Config/CIImaTgfD8S" host=vi-da-sta.herokuapp.com request_id=... fwd="12.211.213.333" dyno=web.1 connect=0ms service=201ms status=200 bytes=522
 app[web.1]: /app/node_modules/parse-server/lib/ParseServer.js:425
 app[web.1]:             throw err;
 app[web.1]:             ^
 app[web.1]: 
 app[web.1]: Error: ENOENT: no such file or directory, open '/cloud/MyApp.Prod.p12'
 app[web.1]:     at Error (native)
 app[web.1]: 
 app[web.1]: npm ERR! Linux 3.13.0-100-generic
 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
 app[web.1]: npm ERR! node v6.9.1
 app[web.1]: npm ERR! npm  v3.10.8
 app[web.1]: npm ERR! code ELIFECYCLE
 app[web.1]: npm ERR! parse-server-example@1.4.0 start: `node index.js`
 app[web.1]: npm ERR! Exit status 7
 app[web.1]: npm ERR! 
 app[web.1]: npm ERR! Failed at the parse-server-example@1.4.0 start script 'node index.js'.
 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
 app[web.1]: npm ERR! If you do, this is most likely a problem with the parse-server-example package,
 app[web.1]: npm ERR! not with npm itself.
 app[web.1]: npm ERR! Tell the author that this fails on your system:
 app[web.1]: npm ERR!     node index.js
 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
 app[web.1]: npm ERR!     npm bugs parse-server-example
 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
 app[web.1]: npm ERR!     npm owner ls parse-server-example
 app[web.1]: npm ERR! There is likely additional logging output above.
 app[web.1]: 
 app[web.1]: npm ERR! Please include the following file with any support request:
 app[web.1]: npm ERR!     /app/npm-debug.log
 heroku[web.1]: State changed from up to crashed
 heroku[web.1]: Process exited with status 1
 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/parse/logout" ...... dyno=web.1 connect=0ms service= status=503 bytes=
 heroku[web.1]: State changed from crashed to starting
 heroku[web.1]: Starting process with command `npm start`
 app[web.1]: 
 app[web.1]: > parse-server-example@1.4.0 start /app
 app[web.1]: > node index.js
 app[web.1]: 
 app[web.1]: parse-server-example running on port 19647.
 app[web.1]: info: Parse LiveQuery Server starts running
 heroku[web.1]: State changed from starting to up

即使上面的日志非常模糊,我仍可以注意到其中的部分內容:

Error: ENOENT: no such file or directory, open '/cloud/MyApp.Prod.p12'

但是我確定MyApp.Prod.p12在本地存在於雲文件夾下。 通過運行:

heroku run bash

我還可以檢查它實際上在服務器上。

可能是我將.p12文件放在錯誤的位置嗎? 或者是其他東西?

Instead of pfx: '/cloud/MY_APP.Dev.p12',  

Use pfx: 'cloud/MY_APP.Dev.p12',

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM