How to save multiple objects using PARSE library from android - android

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.

Related

Google api for device provisioning services fails on configuration creation

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.

Configure push notification with parse-server

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

Sending push notifications to app in limited setup - fake_push_profile not found Ionic

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.

Parse Server: Can not find sender for push type android

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": "..."
},

AWS Device Farm - Failed upload when using the CLI

I am trying to upload an apk to device farm using a bash script, I have used the create-upload endpoint to get a pre-signed url for the put request, and then I am using curl to PUT the apk to the end point.
RESPONSE=$(aws devicefarm create-upload --project-arn %deviceFarmProjectARN% --name platforms/android/build/outputs/apk/android-release-unsigned.apk --type ANDROID_APP --content-type application/octet-stream)
APK_ARN=$(echo "$RESPONSE" | grep arn:aws:devicefarm | gawk 'match($0, "(arn:aws:devicefarm(.*))\"", ary) {print ary[1]}')
APK_PUT_URL=$(echo "$RESPONSE" | gawk 'match($0, "\"url\": \"(.*)\"", ary) {print ary[1]}')
echo "$APK_ARN" >> apkARN.txt
curl $APK_PUT_URL -X PUT --upload-file platforms/android/build/outputs/apk/android-release-unsigned.apk -H "Content-Type:application/octet-stream"
The file upload seems to work, but when I check the status using the returned ARN the status is failed, and the reason is "Invalid application uploaded"
"upload": {
"status": "FAILED",
"contentType": "application/octet-stream",
"name": "platforms/android/build/outputs/apk/android-release-unsigned.apk",
"created": 1437582538.139,
"type": "ANDROID_APP",
"arn": "arn:aws:devicefarm:us-west-2:208791684493:upload:a9153182-8e03-4bc3-a5db-bc02034f1331/190ac7a5-bdc4-46f2-aac2-46bb994f2cf3",
"metadata": "{\"errorMessage\":\"Invalid application uploaded.\"}"
}
However when I upload exactly the same file through the GUI, on the web console, the application is fine, and I can run tests against it.
the upload name only accepts word characters. The upload is failing because of the forward slashes in the name.

Categories

Resources