Back4app issue in registering device with ionic 3
Back4app issue in registering device with ionic 3
I m trying to use back4app for push notification. For this I have installed back4app's ionic sdk (https://www.back4app.com/docs/ionic/parse-ionic-sdk) like this
back4app
back4app
npm install parse
npm install parse
then in my app.component.ts I imported parse
app.component.ts
import Parse from 'parse';
and in platform ready
Parse.serverURL = "https://parseapi.back4app.com/";
Parse.initialize("APP_ID_HERE", "JAVASCRIPT_KEY"); //I have used real keys from back4app dashboard.
let install = new Parse.Installation();
install.save(null, {
success: (install) => {
// Execute any logic that should take place after the object is saved.
// console.clear();
console.error('New object created with objectId: ' + install.id);
},
error: (install, error) => {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
//console.clear();
console.error('Failed to create new object, with error code:' + error.message.toString());
}
});
When I do Ionic serve or test it in device, it should register device/installation id to their backend but it gives 400 Bad Request error on https://parseapi.back4app.com/classes/_Installation the error was -
400 Bad Request error on https://parseapi.back4app.com/classes/_Installation
{"code":135,"error":"deviceType must be specified in this operation"}
I m not sure where to mention deviceType as their documentation doesn't seem that good.
deviceType
Can anybody help me on this??
2 Answers
2
Parse SDK now supports Promises.
Promises
I'd recommend using it instead of passing in callbacks.
You can accomplish that by:
install.save().then(() => {
// success
}, err => {
// error
})
This is not mentioned in their documentation but I have found it in one of their example.
Replacing -
let install = new Parse.Installation();
with
let install = new Parse.Installation();
install.set("deviceType", platform.platforms().toString());
Solved the issue.
Here is the link to their repository
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.