Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Test Push notification is not shown #23

Open
sahilpma opened this issue Nov 23, 2022 · 3 comments
Open

Test Push notification is not shown #23

sahilpma opened this issue Nov 23, 2022 · 3 comments
Assignees

Comments

@sahilpma
Copy link

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

`

<!-- Unity Main Activity -->
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
  </intent-filter>
  <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
  <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>

<!-- Flurry Agent settings; please update -->
<meta-data android:name="flurry_apikey" android:value="VVXB429474W45G35MHKS" />
<meta-data android:name="flurry_with_crash_reporting" android:value="true" />
<meta-data android:name="flurry_with_continue_session_millis" android:value="10000L" />
<meta-data android:name="flurry_with_include_background_sessions_in_metrics" android:value="true" />
<meta-data android:name="flurry_with_log_enabled" android:value="true" />
<meta-data android:name="flurry_with_log_level" android:value="2" />
<meta-data android:name="flurry_with_messaging" android:value="true" />

<!-- Flurry Messaging services; do not modify -->
<service android:name="com.flurry.android.marketing.messaging.FCM.FlurryMessageListenerService">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
</service>

<service android:name="com.flurry.android.marketing.messaging.FCM.FlurryInstanceIDListenerService">
  <intent-filter>
    <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
  </intent-filter>
</service>

<receiver
        android:name="com.flurry.android.marketing.messaging.notification.NotificationCancelledReceiver"
        android:enabled="true"
        android:exported="false">
</receiver>

<receiver
        android:name="com.flurry.android.marketing.messaging.notification.NotificationClickedReceiver"
        android:enabled="true"
        android:exported="false">
</receiver>

<service android:name="com.google.firebase.messaging.MessageForwardingService"
         android:permission="android.permission.BIND_JOB_SERVICE"
         android:exported="false" >
</service>

`

image

Please assist me in this.

@poting-oath poting-oath self-assigned this Nov 28, 2022
@poting-oath
Copy link
Collaborator

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">
  1. 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>
  1. 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
Copy link
Collaborator

@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
Copy link
Collaborator

@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;
        }
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants