react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

Notification duplicate on android

Open avdept opened this issue 9 years ago • 16 comments

When i send remove notification - i receive it, but rn-notification also shows it in notification center, even though i didn't call localNotification(). Any ideas what could go wrong?

avdept avatar Jul 24 '17 12:07 avdept

@avdept, this is because library internally calls the local notification.

See code postNotification(null); in the file PushNotification.java on line 60. This code still has some issue, but for now, you can just comment that line.

I will soon create PR for the same.

Thanks

BhadraSoft avatar Dec 15 '17 06:12 BhadraSoft

@BhadraSoft however, when I called localNotification(). I get 2 notifications instead of 1. any Idea why?

I noticed the NotificationsAndroid ReceivedListener got 2 messages, I am guessing the app listens to GCM and FCM.

any Ideas?

Jp3rd avatar Jan 09 '18 10:01 Jp3rd

@Jp3rd, Can you please attach your AndroidManifest.xml file. There might be the issue regarding the setup.

BhadraSoft avatar Jan 10 '18 16:01 BhadraSoft

@BhadraSoft my bad, here you go


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="sg.flair.android"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <permission
        android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    
    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23" />
    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"      
      xmlns:tools="http:/schemas.android.com/tools"            
      >
      <meta-data android:name="com.wix.reactnativenotifications.gcmSenderId" android:value="786882185947\0"/>
   
      <service
        android:name="com.robinpowered.react.Intercom.IntercomIntentService"
        android:exported="false">
        <intent-filter
            android:priority="999">
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        </intent-filter>
      </service> 
    <receiver
     android:name="io.intercom.android.sdk.push.IntercomPushBroadcastReceiver"
     tools:replace="android:exported" />
      <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
        android:launchMode="singleInstance">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
     <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <data android:scheme="flairapp"/>
          <data android:scheme="flairapp" android:host="login"/>
          <data android:scheme="flairapp" android:host="logout"/>
        </intent-filter>
        <intent-filter>
            <action android:name="fcm.flair.notification" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
            <meta-data
          android:name="io.fabric.ApiKey"
          android:value="3b55e16b67d026d4cf89e8c35ff7e67323d2a1b2"
      />
    </application>
</manifest>

Jp3rd avatar Jan 12 '18 02:01 Jp3rd

@Jp3rd ,

Thanks for sharing file. You can try following things for the issue related to FCM and GCM.

  1. If you are calling the local notification where the push notification is received, try removing the code for the local notification. If you still get the notification, then follow the solution provided in an earlier answer.

2.If a problem persists, It might be an issue regarding the both having FCM and GCM configuration, In that case, you can try upgrading project to FCM from GCM.

If you need assistance with your code, you can drop me a mail @ [email protected].

Thanks BhardaSoft

BhadraSoft avatar Jan 12 '18 18:01 BhadraSoft

@BhadraSoft thanks for the advices!

so I what I did was:

  1. Removing the local notification, and it did not show, but the listener functions still runs twice.
  2. I checked on the android side, OnMessageReceived function, it only runs once.

So in conclusion, FCM and GCM wasn't the problem.

so, I am guessing its an issue where react native/the lib already called the function and this library called it again. So I'm trying to find out that problem.

Update

solved the problem, it was a saga issue i had, my bad.

Jp3rd avatar Jan 15 '18 02:01 Jp3rd

@Jp3rd how did you solved this? I have this issue

cristianonescu avatar Jul 04 '18 13:07 cristianonescu

Ive just solved this, for me it was a duplicate of permissions in my androidManifest.xml

builtbyproxy avatar Nov 12 '18 01:11 builtbyproxy

I had to remove <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

from AndroidManifest.xml

abhaykumar1415 avatar Mar 23 '19 10:03 abhaykumar1415

I had to remove <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

from AndroidManifest.xml

This worked for me, thanks

mldoscar avatar Jun 30 '19 17:06 mldoscar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jul 30 '19 17:07 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Aug 06 '19 17:08 stale[bot]

It seems to be double notification receiver: FCM and GCM. Solution of @abhaykumar1415 work for me

quyen91 avatar Aug 19 '19 09:08 quyen91

when I register in app first time,i received one notification and after that I register in app again and send notification twice and increase notification for every register in app.

mahsabeyghole avatar May 01 '20 15:05 mahsabeyghole

@mahsabeyghole +1

NSNJRGL avatar May 02 '20 23:05 NSNJRGL

This is exactly what I'm experiencing.

mjmostachetti avatar Mar 05 '23 05:03 mjmostachetti