2

Recently I setup Firebase In-App Messaging in my existing project, but when I'm running the application for testing I'm getting PERMISSION_DENIED issue. The project already using many other services of firebase like FCM, Dynamic Links, Crashlytics, etc and all are working fine. Please help it out.

Configurations I have done

Dependencies in app gradle

implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.2'

The firebase logs are

    I/FIAM.Headless: Starting InAppMessaging runtime with Instance ID cNqdR69UnlM
    I/FIAM.Headless: Setting display event listener
    I/FIAM.Headless: went foreground
    I/FIAM.Headless: Forcing fetch from service rather than cache. Test Device: false | App Fresh Install: true
    I/FIAM.Headless: Recoverable exception while reading cache: /data/user/0/com.social.dapp.debug/files/fiam_impressions_store_file (No such file or directory)
    I/FIAM.Headless: Fetching campaigns from service.
    I/FIAM.Headless: Removing display event listener
    W/FIAM.Headless: Service fetch error: PERMISSION_DENIED: Requests from this Android client application com.social.dapp.debug are blocked.
    I/FIAM.Headless: Setting display event listener
    I/FIAM.Headless: Removing display event listener
Nicholas
  • 501
  • 2
  • 14
Nilesh Rathore
  • 886
  • 1
  • 12
  • 22
  • Could you post the full error message that you are getting? – Enrique Del Valle Dec 17 '19 at 21:49
  • @EnriqueDelValle There are no other logs, I guess this is the main error in the logs **W/FIAM.Headless: Service fetch error: PERMISSION_DENIED: Requests from this Android client application com.social.dapp.debug are blocked.** – Nilesh Rathore Dec 18 '19 at 11:19

4 Answers4

1

It started to work in my release build. Yesterday I build the signed app and uploaded it to the play store and in that app In-App Messaging working utterly fine, I still don't know why it is not working in debug app while I have configured right SHA1 for debugging app also and all other services of firebase also working fine in debug.

Nilesh Rathore
  • 886
  • 1
  • 12
  • 22
0

You have to add rules for your app in Firebase, go to:

Firebase console -> select your project -> Database -> Rules -> and add: allow read allow write

For security reasons I recomend you read this article first

https://firebase.google.com/docs/rules

  • I already have these rules in firebase realtime database **{ "rules": { ".read": true, ".write": true } }** Do I need to add in Cloud Firestore also? – Nilesh Rathore Dec 17 '19 at 13:46
  • Forget about my previous comment, I thought you wanted to use Cloud Firestore. I'm not sure what your problem might be, so we must rule out some possibilities. If you have everything set up correctly, you should be able to get the Firebase token, so if this code works (java code) and you get a correct token, we can discard that problem. FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(instanceIdResult -> { String firebaseToken = instanceIdResult.getToken(); Log.d(TAG, "InstanceID token: " + firebaseToken); }); – Héctor López Dec 17 '19 at 16:09
  • Also, you have to add debug AND release version of your project to firestore – Héctor López Dec 17 '19 at 16:18
  • 1
    I didn't understand, is there any relationship between **In-App Messaging** and **Cloud Firestore** ? – Nilesh Rathore Dec 18 '19 at 12:34
  • No, there isn't any direct relationship between In-App Messaging and Cloud Firestore. Cloud Firestore it's a NoSQL database and In-App Messaging it's a different service that just sends messages to any device that has a valid Firestore token created. I think your problem could be that you configured your project in Firebase only for release variant and you are running the application for testing with debug variant. – Héctor López Dec 18 '19 at 15:24
  • Firebase configuration is all right for both apps(release and debug), and all other services of firebase working fine in both apps. – Nilesh Rathore Dec 18 '19 at 16:54
0

I have seen on github firebase/firebase-android-sdk repository(https://github.com/firebase/firebase-android-sdk/issues/133) a issue like yours and they resolve it Re-imported google-services.json from console.

0

I noticed that this issue occurs if you integrate In-App messaging and update the existing build in the device. If you uninstall and freshly install the build it will start working

Vinay Revankar
  • 823
  • 9
  • 19