evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

Custom Data is Not Receiving #926

Open haideralishah opened 6 years ago

haideralishah commented 6 years ago
  1. What version of RN and react-native-fcm are you running? react-native": "0.51.0",

  2. What device are you using? (e.g iOS9 emulator, Android 6 device)? iOS emulator and android 5 device

  3. Is your app running in foreground, background or not running? My app is working fine and also receiving notifications.

Issue#1 I am unable to get custom data (key:value) sent along the notification in the app, while it was working before. (I was getting data before but from last 1 week it stopped and not getting custom data)

Issue#2 I closed the app and open the app again, it is trigerring and bringing notification via getInitialNotification method. So is there any possibility that it will only go in success of getInitialNotification if there is a click on notification and not for old notification.


My MainApplication.java package com.mageapp;

import android.app.Application;

import com.facebook.react.ReactApplication; import org.devio.rn.splashscreen.SplashScreenReactPackage; import com.evollu.react.fcm.FIRMessagingPackage; // import io.invertase.firebase.RNFirebasePackage; import com.zmxv.RNSound.RNSoundPackage; import com.inprogress.reactnativeyoutube.ReactNativeYouTube; import com.bubblemessage.BubbleMessagePackage; import io.linkpreview.RNReactNativeLinkPreviewPackage; import co.apptailor.googlesignin.RNGoogleSigninPackage; import com.facebook.reactnative.androidsdk.FBSDKPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.facebook.CallbackManager; // import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; import java.util.Arrays; import java.util.List;

public class MainApplication extends Application implements ReactApplication { private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

protected static CallbackManager getCallbackManager() { return mCallbackManager; }

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; }

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new SplashScreenReactPackage(),
        new FIRMessagingPackage(),
        // new RNFirebasePackage(),
        new RNSoundPackage(),
        //  new RNFirebaseMessagingPackage(),
        new ReactNativeYouTube(),
        new BubbleMessagePackage(),
        new RNReactNativeLinkPreviewPackage(),
        new RNGoogleSigninPackage(),
        new FBSDKPackage(mCallbackManager)
  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }

@Override public void onCreate() { super.onCreate(); SoLoader.init(this, / native exopackage / false); } }



MainActivity.java

package com.mageapp;

import com.facebook.react.ReactActivity; import com.inprogress.reactnativeyoutube.ReactNativeYouTube; import co.apptailor.googlesignin.RNGoogleSigninPackage; import com.facebook.reactnative.androidsdk.FBSDKPackage; import com.facebook.reactnative.androidsdk.FBSDKPackage; import android.content.Intent; import android.os.Bundle;

import org.devio.rn.splashscreen.SplashScreen;

public class MainActivity extends ReactActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this);
    super.onCreate(savedInstanceState);
}
/**
 * Returns the name of the main component registered from JavaScript.
 * This is used to schedule rendering of the component.
 */
@Override
protected String getMainComponentName() {
    return "mageApp";
}

@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
}

 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}

}


evollu commented 6 years ago

issue 1: I am unable to get custom data (key:value) sent along the notification in the app

If you are setting data together with notification. Data will be ignored in Android when the app is in the background. Is this what you are expecting?

issue 2 try to move the get initial notification either outside of component lifecycle or put in in root level component

Sumit-Chakole commented 5 years ago

If you are setting data together with notification. Data will be ignored in Android when the app is in the background. Is this what you are expecting?

How to open a specific screen on click of Notification from drawer then?