add env variables to the push adapter?
Hi Guys
Is is possible to add ENV variables to the push adapter? (Like we have just done for the S3 adapter in version 2.1.5)
or is this already available? PARSE_SERVER_PUSH?
Trying to set it in a json config with little success. Im not using the parse-server-example so i don't make use of a index.js initializer.
Making use of the oneSignalPushAdapter.
you can configure with a PARSE_SERVER_PUSH or --push we expect the contents to be a string that can be parsed as a JSON.
in the JSON:
{ module: full/path/to/OSPushAdapter, options: { // one signal options } }
then JSON.stringify(pushOptions)
PARSE_SERVER_PUSH="
@flovilmart Thanks , so if understand correctly in my ecosystem.json file I can set this full string in the PARSE_SERVER_PUSH="" ?
That should work :) Let me know. BE careful with the path to the pushAdapter, this is tricky.
The adapterLoader is in Adapter, so it should work passing: '{"module": "./Push/OneSignalPushAdapter", "options": {}}'
./ being the relative path to the current file which is the adapterLoader
npm start -- --appId app --masterKey master --push '{"adapter": "./Push/OneSignalPushAdapter"}'
> [email protected] start /Users/florent/src/Parse/parse-server
> node ./bin/parse-server "--appId" "app" "--masterKey" "master" "--push" "{\"adapter\": \"./Push/OneSignalPushAdapter\"}"
/Users/florent/src/Parse/parse-server/lib/Adapters/Push/OneSignalPushAdapter.js:49
throw "Trying to initialize OneSignalPushAdapter without oneSignalAppId or oneSignalApiKey";
^
Trying to initialize OneSignalPushAdapter without oneSignalAppId or oneSignalApiKey
how do you write it in PUSH_SERVER_PUSH, I amalso not using index.js and I need to use this env var in my ecosystem but the parse is ignoring it so when I am trying to send Push it tells me It cannot find a sender...
PARSE_SERVER_PUSH is an environment variable, just set it to the stringified JSON
I did this and it doesnt work "PARSE_SERVER_PUSH": "'ios': [ { 'pfx': '/home/parse/dev_cert.p12', 'bundleId': 'SomeID', 'production': false },{ 'pfx': '/home/parse/production_cert.p12', 'bundleId': 'SomeID', 'production': true }]"
The value you just set is not a valid JSON, PARSE_SERVER_PUSH='{"ios": [] }'
it doesnt work too, parse is ignoring the PARSE_SERVER_PUSH { "apps" : [{ "name" : "parse-wrapper", "script" : "/usr/bin/parse-server", "watch" : true, "merge_logs" : true, "cwd" : "/home/parse", "env": { "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js", "PARSE_SERVER_DATABASE_URI": "mongodb:...", "PARSE_SERVER_APPLICATION_ID": "id", "PARSE_SERVER_MASTER_KEY": "master", PARSE_SERVER_PUSH="{'ios': [ { 'pfx': '/home/parse/dev_cert.p12', 'bundleId': 'someID', 'production': false },{ 'pfx': '/home/parse/production_cert.p12', 'bundleId': 'someID', 'production': true }] }" } }] }
Your configuration is malformed!
{
"apps" : [{
"name" : "parse-wrapper",
"script" : "/usr/bin/parse-server",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse",
"env": {
"PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
"PARSE_SERVER_DATABASE_URI": "mongodb:...",
"PARSE_SERVER_APPLICATION_ID": "id",
"PARSE_SERVER_MASTER_KEY": "master",
"PARSE_SERVER_PUSH": "{'ios': [ { 'pfx': '/home/parse/dev_cert.p12', 'bundleId': 'someID', 'production': false },{ 'pfx': '/home/parse/production_cert.p12', 'bundleId': 'someID', 'production': true }] }"
}
}]
}
it doesnt work for me.... it keeps telling me in log that it cant find sender for push type..... I tried that on parse 2.1.4 and now on 2.1.6...
Try to do it in a development environment, without pm2, I'm not familiar with pm2. but I can tell you that it works when properly setting environment variables. and running directly from command line
@KudosGuy did you have any luck with this? Trying both OneSignal and the default with little success.
no, I tried like 10 times to start the server with parse-server jsonconfig.json or npm start parse-server and many more and nothing worked, I would report it as a bug and maybe we can get more attention to this, but if you will install parse-server-example you will have the index.js and it is working there, but i really dont know why they are these two versions...
I can confirm PARSE_SERVER_PUSH certainly does work. I got it to select the adapter ( OneSignal ) but struggling to pass the variables through. But i'm giving it a bash now.
@Cliffordwh could you show me the syntax you used for PARSE_SERVER_PUSH?
Options tho, doesn't seem to work for me. I'm getting Trying to initialize OneSignalPushAdapter without oneSignalAppId or oneSignalApiKey
"PARSE_SERVER_PUSH" : {"adapter" : "./Push/OneSignalPushAdapter",
"options" : {
"oneSignalAppId": "appid",
"oneSignalApiKey": "apikey"
}
}
I got it running that I hardcoded it in /usr/lib/node_modules/parse-server/lib/cli/cli-definitions.js
"push": {
env: "PARSE_SERVER_PUSH",
help: "Configuration for push, as stringified JSON. See https://github.com/$",
default: {
ios: {
pfx: "/home/parse/dev_cert.p12",
bundleId: "someApp",
production: false
}
}
}
Glad you got it working. I ended up coding in env's variables for the options too.
Guys, this is not how it should be configured
@flovilmart could you extend your response why? because for me it is the only solution for now... becasue when I add in my ecosystem.json PARSE_SERVER_PUSH it is never initialized, I can see that in log... but with my solution in cli-definitions.js it loads it on startup fine...