Ionic push - GCM_INVALID_AUTH - android

I'm developing an Ionic (version 1.3.1) application and trying use Ionic push.
The application is correctly registering to ionic server but I still don't receive any notification in my device. The only error I get is the below notification status:
{
"notification": "808cde89-eb21-40d7-9999-b86e5f86f1d3",
"token": {
"type": "android",
"token": "dkYxYGcKeNo:APA91bE4OXhzkOUOSF1EsXxgY9Cd0Uu9-A98Ak5prdMIGUd10tLljacgKs7zAp1WPLF-bDiy3pkdroc9l8vWy4sXdfansr56-rIF59wJfR1e7EibJZHFO5DFxCThpT_ZgVn_T_0n8an1",
"id": "ea40d3bc7561cc4f0d28ac49ce87fd3a",
"app_id": "7ab91503",
"invalidated": null,
"created": "2016-09-17T11:31:53.481151+00:00",
"valid": true
},
"uuid": "0ebe9454-aebc-4c0b-b5b0-056920817f56",
"status": "error",
"error": "GCM_INVALID_AUTH",
"created": "2016-09-17T14:31:20.517783+00:00",
"user_id": null
}
I'm supposing ionic server is not sending the notification to device as the status is error, but I don't know the reason why I'm getting this GCM_INVALID_AUTH error. What could cause this problem?

You need migrate your project from GCM to FCM (firebase cloud message) , and use new server key.

SOLVED
I was using the wrong credentials from Google Cloud Platform. When I set to server key the problem was solved.

Related

Firebase installation is not working in play store application

I am facing a wired issue when ill create a release build firebase installation is working properly and firebase authentication token generating but after uploading same apk to play store its not working please help me out. here is error returned by firebase.
2022-04-05 15:19:11.865 9614-9649/? W/Firebase-Installations: Error when communicating with the Firebase Installations server API. HTTP response: [403 Forbidden: {
"error": {
"code": 403,
"message": "Requests from this Android client application com.wrms.secu.trak are blocked.",
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_ANDROID_APP_BLOCKED",
"domain": "googleapis.com",
"metadata": {
"service": "firebaseinstallations.googleapis.com",
"consumer": "projects/28778611780"
}
}
]
}
}
]
2022-04-05 15:19:11.865 9614-9649/? E/Firebase-Installations: Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.

React Native Firebase Push Notification not getting received in Release Build

Please guide me to get it resolved please.
I have installed below npm packages to integrate firebase push notification.
"#react-native-firebase/app": "^8.4.5",
"#react-native-firebase/messaging": "^7.9.0",
I receive notification in debug mode but if i release the build notification is not working at all.
Here is payload i am using -
{
"notification": {
"title": "notification title",
"body": "notification is ready.",
"click_action": null,
"icon": null
},
"data": {
"xyz":"test",
"click_action": null
},
"to":"xxxxxx",
"content_available": true
}

Error when communicating with the Firebase Installations server API - 403 Forbidden

A have a big project with a lot of dependencies including Firebase.
Now com.google.firebase:firebase-messaging has version 17.3.3. I want to update it to the 20.2.1.
I'm getting next error after app has started:
Firebase-Installations: Error when communicating with the Firebase Installations server API. HTTP response: [403 Forbidden: {
"error": {
"code": 403,
"message": "Requests from this Android client application com.example are blocked.",
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/61947752567/apiui/credential"
}
]
}
]
}
}
]
Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.
We use google-services.json to configure FCM in our app. We do not use FirebaseOptions in code.
I've noticed that the problem is connected with updating FCM to 20.1.1. And what Google says about FCM 20.1.1:
The Firebase Cloud Messaging and Firebase Instance ID SDKs now transitively depend on the Firebase installations SDK. If you use Cloud Messaging and update your dependencies to their latest versions, make sure that push notifications still work as expected.
I read an instruction from Google but no success. What I tried:
Re-download google-services.json from Firebase console. No success because it's identical.
Apply instruction about API-Key restrictions inside Firebase Console. It turned out that we don't have any restrictions ("Don't restrict key" option is checked).
Update all of Firebase (including firebase-perf) and GCM dependencies to the latest versions. No changes.
Set App ID, project ID and API-Key with FirebaseOptions right in the code before calling initializeApp method.
It also turned out that installed from APK application works correctly! If I use .aab (App Bundle) - I'm getting this error. I also use the latest bundletool.
firebase-messaging is included into our main app-module and it's one of the main features of application. I'm not talking about dynamic modules - the problem is with the main module.
I can't setup FCM again because there are a lot of users who use this application now. Also I can't understand why I have to set valid options (API key, Project ID, Application ID) if this options work great for last few years and google-services.json has not changes.
I will be grateful for any ideas.
P.S. I can't use FCM 20.1.0 because I need to integrate ML Kit dependency. It works only with actual version of FCM and crashes with FCM 20.1.0
Sometimes the project needs a simple rebuild/clean as precompiled outdated files (json/xml) stays in the precompiled version of the project.
Run in Android IDE: Build -> "Clean Project" and "Build" -> "Rebuild Project".
This won't help in all cases. Redownloading the google-services.json file may be better instead of editing/checking it manually. Don't forget to rebuild/clean after replacing the file.
In my case, I made 2 applicatiions in 1 firebase project. google-services.json downloaded from firebase has 2 client informations. I get the same error with this setup.
{
"project_info": {
"project_number": "xxxxxx",
"firebase_url": "xxxxxx.firebaseio.com",
"project_id": "xxxxxx",
......
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "xxxxxx",
"android_client_info": {
"package_name": "application-1"
}
},
.......
"api_key": [
{
"current_key": "(API-Key for application1)"
},
{
"current_key": "(API-Key for application2)"
}
],
.......
},
{
"client_info": {
"mobilesdk_app_id": "xxxxxx",
"android_client_info": {
"package_name": "application-2"
}
},
......
"api_key": [
{
"current_key": "(API-Key for application1)"
},
{
"current_key": "(API-Key for application2)"
}
],
......
}
],
"configuration_version": "1"
}
I edited google-services.json and made it simple for application-2. This works well.
{
"project_info": {
"project_number": "xxxxxx",
"firebase_url": "xxxxxx.firebaseio.com",
"project_id": "xxxxxx",
......
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "xxxxxx",
"android_client_info": {
"package_name": "application-2"
}
},
......
"api_key": [
{
"current_key": "(API-Key for application2)"
}
],
......
}
],
"configuration_version": "1"
}

Ionic not sending push notification

I'm using ngCordova cordovaPushV5 and when I open the app I get the registration id just fine, but when I send the notification via POST request using Postman I do not get a notification on the device.
Here is the curl request I'm trying:
curl -X POST -H "Authorization: Bearer MY_API_TOKEN" -H "Content-Type: application/json" -d '{
"tokens": ["dO-ocODiZSE:APA91bFTEvGakImDE3Jk-qhYyGwl86qq4R8bQuKikaQeyeYmDkaxWjMZTv47SmX0rvYUWLjpeG24LsQYIuE2KJA0I4U9Hq-2HyG9LuST3jn5SwLc1FTYQbyttIuKaGKHMDMTIaTdLyIx"],
"profile": "trader_mobile",
"notification": {
"message": "Test"
}
}' "https://api.ionic.io/push/notifications"
And this is the response I get:
{
"meta": {
"request_id": "5ac67cae-458e-4ff4-aa9a-ac86f4aff873",
"version": "2.0.0-beta.0",
"status": 201
},
"data": {
"app_id": "de12c106",
"status": "open",
"config": {
"profile": "trader_mobile",
"tokens": [
"dO-ocODiZSE:APA91bFTEvGakImDE3Jk-qhYyGwl86qq4R8bQuKikaQeyeYmDkaxWjMZTv47SmX0rvYUWLjpeG24LsQYIuE2KJA0I4U9Hq-2HyG9LuST3jn5SwLc1FTYQbyttIuKaGKHMDMTIaTdLyIx"
],
"notification": {
"message": "Test"
}
},
"uuid": "7efef50c-72bf-4e08-a176-4c28de8b2258",
"state": "enqueued",
"created": "2016-09-05T17:00:46.425695+00:00"
}
}
But I still do not receive the notification on the device.
I've set up my gcm api key in my security profile in my Ionic Dashbaord, and uploaded my app with ionic upload and did ionic io init. I've tried every solution I could find, and I've tried just about every command in different orders. As well as removing the platform and adding it again. Still nothing, what am I doing wrong?

Appcelerator Push Notification error on Android only

Titanium version: 3.1.3.
I'm still using MQTT for Android and everything worked fine until a few weeks ago (maybe until mqtt on acs got deprecated). But I read that it is possible to still use MQTT (instead of gcm). According to another post on appcelerator I just had to define mqtt in the tiapp.xml, but this does not work.
This is part of my tiapp.xml
<property name="acs-push-type-development" type="string">mqtt</property>
<property name="acs-push-type-production" type="string">mqtt</property>
<property name="acs-push-type" type="string">mqtt</property>
...
<module platform="android" version="2.3.2">ti.cloudpush</module>
<module platform="android" version="2.1.2">ti.map</module>
<module platform="commonjs" version="2.3.7">ti.cloud</module>
That is what I get from the appcelerator logs:
`"response": {"push_log_details": [
{
"created_at": "2014-05-12T13:02:35.389Z",
"updated_at": "2014-05-12T13:02:31.094Z",
"type": "android",
"android_type": 1,
"app_id": "52724d7cd72ec85152039256",
"channel": "stickin",
"_id": "5370c66be511ea7ab99881d4",
"token": "ND1M2IX8RU8RGJDICW13I9V",
"push_id": "5370c6641316e90db2311567",
"send_status": 2,
"sent_at": "2014-05-12T13:02:30.996Z",
"error_message": "argument cannot be null",
"msg_id": "fa89cfb6-f2d2-4222-b442-a47d2625b419"
},
{
"created_at": "2014-05-12T13:02:35.389Z",
"updated_at": "2014-05-12T13:02:31.094Z",
"type": "android",
"android_type": 1,
"app_id": "52724d7cd72ec85152039256",
"channel": "stickin",
"_id": "5370c66be511ea7ab99881d6",
"token": "ND13ST3OA0MHE079H6EYV8P",
"push_id": "5370c6641316e90db2311567",
"send_status": 2,
"sent_at": "2014-05-12T13:02:30.996Z",
"error_message": "argument cannot be null",
"msg_id": "77fc5c7f-9703-46e5-a433-7be0796421f2"
}, .....
`
"argument cannot be null" seems like a gcm response code. I tried removing apiKey and sender id of gcm and to only save the Application Packagename (MQTT), but then I get the error gcm_apiKey is null. I thought push is not using gcm if I define mqtt in the tiapp.xml? By the way, on iOS everything is working fine, but of course mqtt is not used there.
Check the following
CloudPush module version you are using should be below 3.2.0
You should specify 'android' as type while subscribing to the push notification. (in the case of GCM, you have to use 'gcm')
However Appcelerator has removed the MQTT support from March 15th 2014..
So latest CloudPush modules will not support MQTT anymore.
See the below screenshot. You may see this on the ACS server. You need to upgrade your app to GCM to fix the issues and upgrading to GCM is pretty simple. I had already done it earlier. I suggest you should upgrade your app to GCM support.
Also visit Android Push Notification: Deprecating MQTT in favor of GCM in Appcelerator Blog.

Categories

Resources