Commit c9b93dfc authored by Libin Lu's avatar Libin Lu

take away FCM.initData

parent 23cf81fe
...@@ -27,14 +27,12 @@ import android.util.Log; ...@@ -27,14 +27,12 @@ import android.util.Log;
import android.content.Context; import android.content.Context;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class FIRMessagingModule extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener { public class FIRMessagingModule extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener {
private final static String TAG = FIRMessagingModule.class.getCanonicalName(); private final static String TAG = FIRMessagingModule.class.getCanonicalName();
private FIRLocalMessagingHelper mFIRLocalMessagingHelper; private FIRLocalMessagingHelper mFIRLocalMessagingHelper;
Intent initIntent;
public FIRMessagingModule(ReactApplicationContext reactContext) { public FIRMessagingModule(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
...@@ -45,12 +43,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li ...@@ -45,12 +43,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
registerMessageHandler(); registerMessageHandler();
} }
@Override
public Map<String, Object> getConstants() {
Map<String, Object> constants = new HashMap<>();
return constants;
}
@Override @Override
public String getName() { public String getName() {
return "RNFIRMessaging"; return "RNFIRMessaging";
...@@ -180,12 +172,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li ...@@ -180,12 +172,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
@Override @Override
public void onHostResume() { public void onHostResume() {
if (initIntent == null){
//the first intent is initial intent that opens the app
Intent newIntent = getCurrentActivity().getIntent();
sendEvent("FCMInitData", parseIntent(newIntent));
initIntent = newIntent;
}
} }
@Override @Override
......
...@@ -6,48 +6,48 @@ const eventsMap = { ...@@ -6,48 +6,48 @@ const eventsMap = {
localNotification: 'FCMLocalNotificationReceived' localNotification: 'FCMLocalNotificationReceived'
}; };
const FIRMessaging = NativeModules.RNFIRMessaging; const RNFIRMessaging = NativeModules.RNFIRMessaging;
const FCM = {}; const FCM = {};
FCM.getInitialNotification = () => { FCM.getInitialNotification = () => {
return FIRMessaging.getInitialNotification(); return RNFIRMessaging.getInitialNotification();
} }
FCM.getFCMToken = () => { FCM.getFCMToken = () => {
return FIRMessaging.getFCMToken(); return RNFIRMessaging.getFCMToken();
}; };
FCM.requestPermissions = () => { FCM.requestPermissions = () => {
return FIRMessaging.requestPermissions(); return RNFIRMessaging.requestPermissions();
}; };
FCM.presentLocalNotification = (details) => { FCM.presentLocalNotification = (details) => {
FIRMessaging.presentLocalNotification(details); RNFIRMessaging.presentLocalNotification(details);
}; };
FCM.scheduleLocalNotification = function(details) { FCM.scheduleLocalNotification = function(details) {
FIRMessaging.scheduleLocalNotification(details); RNFIRMessaging.scheduleLocalNotification(details);
}; };
FCM.getScheduledLocalNotifications = function() { FCM.getScheduledLocalNotifications = function() {
return FIRMessaging.getScheduledLocalNotifications(); return RNFIRMessaging.getScheduledLocalNotifications();
}; };
FCM.cancelLocalNotification = (notificationID) => { FCM.cancelLocalNotification = (notificationID) => {
FIRMessaging.cancelLocalNotification(notificationID); RNFIRMessaging.cancelLocalNotification(notificationID);
}; };
FCM.cancelAllLocalNotifications = () => { FCM.cancelAllLocalNotifications = () => {
FIRMessaging.cancelAllLocalNotifications(); RNFIRMessaging.cancelAllLocalNotifications();
}; };
FCM.setBadgeNumber = () => { FCM.setBadgeNumber = () => {
FIRMessaging.setBadgeNumber(); RNFIRMessaging.setBadgeNumber();
} }
FCM.getBadgeNumber = () => { FCM.getBadgeNumber = () => {
return FIRMessaging.getBadgeNumber(); return RNFIRMessaging.getBadgeNumber();
} }
FCM.on = (event, callback) => { FCM.on = (event, callback) => {
...@@ -60,18 +60,11 @@ FCM.on = (event, callback) => { ...@@ -60,18 +60,11 @@ FCM.on = (event, callback) => {
}; };
FCM.subscribeToTopic = (topic) => { FCM.subscribeToTopic = (topic) => {
FIRMessaging.subscribeToTopic(topic); RNFIRMessaging.subscribeToTopic(topic);
}; };
FCM.unsubscribeFromTopic = (topic) => { FCM.unsubscribeFromTopic = (topic) => {
FIRMessaging.unsubscribeFromTopic(topic); RNFIRMessaging.unsubscribeFromTopic(topic);
}; };
//once doesn't seem to work
DeviceEventEmitter.addListener('FCMInitData', (data) => {
FCM.initialData = data;
});
FCM.initialData = FIRMessaging.initialData;
module.exports = FCM; module.exports = FCM;
...@@ -72,12 +72,6 @@ RCT_EXPORT_MODULE() ...@@ -72,12 +72,6 @@ RCT_EXPORT_MODULE()
@synthesize bridge = _bridge; @synthesize bridge = _bridge;
- (NSDictionary<NSString *, id> *)constantsToExport
{
NSDictionary<NSString *, id> *initialNotification = [_bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] copy];
return @{@"initialData": RCTNullIfNil(initialNotification)};
}
- (void)dealloc - (void)dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment