Hei, i'm trying to send push notification to android app that use parse-server.
My environment is local, and i'm using ubuntu 16.04.
If i try to send push by curl with this:
curl -X POST \
-H "X-Parse-Application-Id: myAppId" \
-H "X-Parse-Master-Key: myMasterKey" \
-H "Content-Type: application/json" \
-d '{
"channels": [""],
"data": {
"alert": "Hello!"
}
}' \
https://localhost:1337/parse/push
i get the error: "missing push configuration"
What configurations should i set? and where?
I'm using Titanium/Alloy to develope the app. I tryed to send push notification directly from the app with:
Parse.Push.send({
where: {
user: {
__type: "Pointer",
className: "_User",
objectId: userId
}
},
data: {
alert: "new notification!",
}
}, {
useMasterKey: true,
success: function() {
console.log("Successfull");
},
error: function(error) {
console.log("Some error occurred");
}
});
but i got the error "Cannot use the Master Key, it has not been provided". So i inizialized parse-server with Parse.initialize(applicationId, javaScriptKey, masterKey) getting still the same error.
Could you help me? It is important :(
Other little question: to create a cloud function with local parse-server on ubuntu, where should i put my main.js file? i have the directory /usr/local/lib/node_modules/parse-server.
If you can answer at least one of this questions, please do! Thanks
Regards, Luca
Related
I am using the device provisioning customer api and I want to create a customer configuration:
curl --location --request POST 'https://androiddeviceprovisioning.googleapis.com/v1/customers/myCustomerId/configurations' \
--header 'Authorization: Bearer myCorrectToken' \
--header 'Content-Type: application/json' \
--data-raw '{
"configurationName": "Config Name",
"companyName": "Company Name",
"contactEmail": "contact#ldifhj.de",
"customMessage": "message",
"contactPhone": "9999",
"isDefault": false,
"dpcResourcePath": "Android Device Policy"
}'
I always get an internal error, I tried various different payloads with no success:
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
When I remove a required parameter in the payload I get 4xx errors, so it's not always 500.
I have followed the instructions to setup a limited setup for push notifications at this article: http://docs.ionic.io/v2.0.0-beta/docs/push-limited-setup
I've got a device ID, and I've registered an API token with Ionic. I have the app running in my browser and am attempting to run
curl -X POST -H "Authorization: Bearer API_TOKEN" -H "Content-Type: application/json" -d '{
"tokens": ["DEV_DEVICE_TOKEN"],
"profile": "fake_push_profile",
"notification": {
"message": "Hello World!"
}
}' "https://api.ionic.io/push/notifications"
In a bash console. However I'm getting an error that looks like this:
"error": {"link": null, "type": "BadRequest", "message": "Security Profile 'fake_push_profile' not found."}}
Got the solution.
You need to create a Profile in your app Dashboard.
Navigate to : Your app setup Page Online
Create a profile and Name it fake_push_profile .
In your .sh file from your where your are sending push you need to enter fake_push_profile in your profile key:
curl -X POST -H "Authorization: Bearer Your_Token" -H "Content-Type: application/json" -d '{
"tokens": ["Device_Token"],
"profile": "fake_push_profile",
"notification": {
"message": "Hello World!"
}
}' "https://api.ionic.io/push/notifications"
That's all you need to do.
Here is the screenshot what I did and it works like a charm.
I did it for iOS.
I do send push notifications with my parse-server like this:
curl -X POST \
-H "X-Parse-Application-Id: XXXXXXXXXXXXXXX" \
-H "X-Parse-Master-Key: XXXXXXXXXXXXXXX" \
-H "Content-Type: application/json" \
-d '{
"where": {
"deviceType": {
"$in": [
"ios"
]
}
},
"data": {
"title": "The Shining",
"alert": "All work and no play makes Jack a dull boy."
}
}'\ https://myserver.com/parse/push
In the logs I always see this error message:
Mar 18 14:35:18 xsn-app parse-app[31790]: Can not find sender for push type android, {"where":{"deviceType":{"$in":["ios"]}},"data":{"title":"The Shining","badge":"1","alert":"All work and no play makes Jack a dull boy."}}
The device does receive the push notification just fine though.
I do not send push notifications to android devices. There is not even one registered. I also have not configured android push in my parse server configuration. There is only one single iOS device registered at the parse server.
Any idea why this happens?
it just tells U that it doesnt know how to send Push for Android. You can get rid of this error if you define the push for android with blank strings...
"android": {
"senderId": "...",
"apiKey": "..."
},
While using
curl -3 -u \
"f07c43a6-bb0a-4bb7-a1eb-a368db272212:e2cf19c3-6636-4712-bbe8-26b7c1ac9c09" \
-v -H "Accept: application/json" -H "Content-type: application/json" \
-X POST -d '{"message": {"alert":"Hello AeroGear", "badge":1}}' \
https://aerogear-html5.rhcloud.com/rest/sender
to push notification
I am getting 401 unauthorised request.Unable to figure out how to authenticate?
Make sure your authorization parameters(through -u) are valid and also make sure you are using the correct credential for the service you are trying to access.
Also, if you are from windows(for linux its ok) then wrap the post parameters with double quotes(") Instead of single(').
-d "{\"message\": {\"alert\":\"Hello AeroGear\", \"badge\":1}}"
Going to this link https://aerogear-html5.rhcloud.com, produces a website not available
Is there a specific tutorial you used to get that curl command?
On my Android application I'm getting the user's likes from facebook running an FQL query and I want to save the results on the PARSE platform.
Instead of saving each object separately is there a way to make a batch request ?
As I found out you can also use the saveAllInBackground static method of ParseObject. You pass in a list of ParseObjects you wish to save.
http://www.parse.com/docs/android/api/com/parse/ParseObject.html#saveAllInBackground(java.util.List)
Using the Parse REST API, you can do batch operations (creating, reading, updating, deleting, etc).
Here is an example of saving a couple objects:
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{
"method": "POST",
"path": "/1/classes/GameScore",
"body": {
"score": 1337,
"playerName": "Sean Plott"
}
},
{
"method": "POST",
"path": "/1/classes/GameScore",
"body": {
"score": 1338,
"playerName": "ZeroCool"
}
}
]
}' \
https://api.parse.com/1/batch
See the Batch Operations section of the Parse REST API Guide for more information.