flurry / unity-flurry-sdk

Unity plugin for Flurry SDK
Apache License 2.0
25 stars 5 forks source link

Test Push notification is not shown #23

Open sahilpma opened 1 year ago

sahilpma commented 1 year ago

I am using Unity 2022.1.14f1 with flurry 6.0.0 version. I have followed the steps as per github docs. I am receiving FCM message, but notification is not shown.

image

image

Here is my manifest file

`<?xml version="1.0" encoding="utf-8"?>

` ![image](https://user-images.githubusercontent.com/38884892/203532676-929669da-7890-49e7-991f-4557717eb7eb.png) Please assist me in this.
poting-oath commented 1 year ago

In the github docs, you need to remove the Firebase sections. It overrides Flurry's settings.

You can safely replace AndroidManifest.xml generated by Firebase with Flurry's.

I.e., replace/remove the following 2 sections.

  1. Use the original com.unity3d.player.UnityPlayerActivity instead of com.google.firebase.MessagingUnityPlayerActivity.
    <!-- Unity Main Activity -->
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  2. Remove the following section, it override Flurry's settings.
    <service android:name="com.google.firebase.messaging.MessageForwardingService"
         android:permission="android.permission.BIND_JOB_SERVICE"
         android:exported="false" >
    </service>
  3. The following section is no longer required.
    <service android:name="com.flurry.android.marketing.messaging.FCM.FlurryInstanceIDListenerService">
    <intent-filter>
    <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
    </service>
poting-oath commented 1 year ago

@sahilpma Have you resolved your issues? Besides the above solutions, please also try the latest version 6.2.0 which fixed several notification migrations (Android 12/13 changed many notification requirements). Thanks!

poting-oath commented 1 year ago

@sahilpma Besides, though the Android developer docs say "recommended" to add POST_NOTIFICATIONS permission for Android 13 and above devices. As I found, it is actually "required" to add this permission! Please do add the following post notification permission to the manifest file:

uses-permission android:name=”android.permission.POST_NOTIFICATIONS”

And in your app, do use ActivityCompat.requestPermissions to request the permission if ContextCompat.checkSelfPermission returns PackageManager.PERMISSION_DENIED. Examples codes,

    private static List<String> PERMISSIONS;
    static {
        PERMISSIONS = new ArrayList<>();
        PERMISSIONS.add(Manifest.permission.ACCESS_FINE_LOCATION);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            PERMISSIONS.add(Manifest.permission.POST_NOTIFICATIONS);
        }
    }
...
    for (String permission : PERMISSIONS) {
        if (ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_DENIED) {
            // Simply request permissions if one of them is missing
            ActivityCompat.requestPermissions(this, PERMISSIONS.toArray(new String[0]), PERMISSION_REQUEST);
            break;
        }
    }