So i have my project and i have setup Ionic push for iOS and it works perfectly but when i copy the same project and try to run it for android. I get this error. I dont know why. Also if i set it up to work for Android, when i copy the project to iOS i get the same error.
"CORE: Unable to load app ID or API key, falling back to $ionicApp.getApp()…
Why is this so?
Must we do ionic io init in our Android and iOS project? because that will open up two projects on apps.ionic which i dont want. I only want just one project on d ionic service.
You replaced the values here with app_id and api_key or that’s how you have them saved?
–
According to Ionic.io documentation if your app_id or app_key are invalid then it should give you error code 1. But since you are getting that other error I’m guessing the Ionic.Push() isn’t even able to reach your config for some reason.
I changed it with the right details. I can reach ionic Push nd it saves my device on the ionic service now but i still get the Warn; CORE: Unable to load app ID or API key, falling back to $ionicApp.getApp()
done all tht. still get the same error message. its weird i know haha bcos it still sends me the device token and saves the user in my app on ionic service. So dont know why im getting the message. Maybe something gets triggered somewhere. Thanks @ihadeed for all the assistance
Track the issue by placing a console.log() before each method call … this will help you identify what is being called before that issue occurs. Then check what that function is doing …
@ihadeed i forgot to mention tht my widget id: in my config.xml for my android and my iOS is different. I had already pushed out the android version to play store when we found out th we couldnt use d same identifier for app store and we had to use another one. Does it me tht it will think the apps r different nd hence cant find d app thts why it gives d error?
Your package identifier (ex: com.example.myapp) and your ionic app id must match what you have on ionic.io. Also your config must be pointing to the same account.
But since you mentioned that it does register on the ionic.io dashboard fine then I highly doubt you have a problem with your configuration, but it’s worth looking into.
@ihaheed i have gotten all to be working now but i want to catch the onNotification event when the push notification is sent from my backend and reset the badge number and also set the state payload tht the page should go to when d notification is clicked on. Nothing happens on my current onNotification event which is like this
var push = new Ionic.Push({
“onNotification”: function(notification) {
console.log(“on notification or smthg”)
alert(‘Received push notification!’);
}
})
So i am not sure when to catch the onNotification event to set the badge number and state payload
you can only catch the onNotification event when the app is in the foreground. what u hv to do is install this plugin cordova-plugin-badge and when d app is in the foreground and u receive a notification, u can update the badge number.
If u want to aslo send a notification when the app is in the foreground, u can use the cordova-local-notification plugin to do tht as well.