Commit edc66ada authored by Libin Lu's avatar Libin Lu

simply logic of receive message, rename package

parent cc821ad4
node_modules node_modules
build
\ No newline at end of file
node_modules node_modules
build
\ No newline at end of file
# react-native-fcm # react-native-gcm-push-notification
Firebase notification for React Native Android and IOS Firebase notification for React Native Android and IOS
## Demo
https://github.com/oney/TestGcm
## Installation ## Installation
- Run `npm install react-native-fcm --save` - Run `npm install react-native-fcm --save`
......
...@@ -65,14 +65,6 @@ ...@@ -65,14 +65,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -81,13 +73,19 @@ ...@@ -81,13 +73,19 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.facebook.react/react-native/0.17.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
...@@ -95,7 +93,6 @@ ...@@ -95,7 +93,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" /> <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" /> <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.oney.gcm"> package="com.evollu.react.firebase">
</manifest> </manifest>
package com.evollu.react.fcm; package com.evollu.react.firebase;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Intent; import android.content.Intent;
...@@ -13,22 +13,19 @@ import com.facebook.react.bridge.ReactMethod; ...@@ -13,22 +13,19 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.messaging.RemoteMessage;
import android.util.Log; import android.util.Log;
import android.content.Context; import android.content.Context;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEventListener { public class FIRMessagingModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
private final static String TAG = FCMModule.class.getCanonicalName(); private final static String TAG = FIRMessagingModule.class.getCanonicalName();
public FCMModule(ReactApplicationContext reactContext, Intent intent) { public FIRMessagingModule(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
getReactApplicationContext().addLifecycleEventListener(this); getReactApplicationContext().addLifecycleEventListener(this);
...@@ -39,7 +36,7 @@ public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEv ...@@ -39,7 +36,7 @@ public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEv
@Override @Override
public String getName() { public String getName() {
return "FCMModule"; return "RNFIRMessaging";
} }
@ReactMethod @ReactMethod
...@@ -59,7 +56,7 @@ public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEv ...@@ -59,7 +56,7 @@ public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEv
} }
private void registerTokenRefreshHandler() { private void registerTokenRefreshHandler() {
IntentFilter intentFilter = new IntentFilter("com.evollu.react.fcm.FCMRefreshToken"); IntentFilter intentFilter = new IntentFilter("com.evollu.react.firebase.FCMRefreshToken");
getReactApplicationContext().registerReceiver(new BroadcastReceiver() { getReactApplicationContext().registerReceiver(new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
...@@ -77,26 +74,25 @@ public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEv ...@@ -77,26 +74,25 @@ public class FCMModule extends ReactContextBaseJavaModule implements LifecycleEv
} }
private void registerNotificationHandler() { private void registerNotificationHandler() {
IntentFilter intentFilter = new IntentFilter("com.evollu.fcm.ReceiveNotification"); IntentFilter intentFilter = new IntentFilter("com.evollu.react.firebase.ReceiveNotification");
getReactApplicationContext().registerReceiver(new BroadcastReceiver() { getReactApplicationContext().registerReceiver(new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (getReactApplicationContext().hasActiveCatalystInstance()) { if (getReactApplicationContext().hasActiveCatalystInstance()) {
RemoteMessage message = intent.getParcelableExtra("data");
WritableMap params = Arguments.createMap(); WritableMap params = Arguments.createMap();
try { if(message.getData() != null){
JSONObject data = new JSONObject(intent.getStringExtra("data")); Map data = message.getData();
Iterator<String> keysIterator = data.keys(); Set<String> keysIterator = data.keySet();
while(keysIterator.hasNext()){ for(String key: keysIterator){
String key = keysIterator.next();
params.putString(key, (String) data.get(key)); params.putString(key, (String) data.get(key));
} }
sendEvent("FCMNotificationReceived", params); sendEvent("FCMNotificationReceived", params);
} catch (JSONException e){
}
abortBroadcast(); abortBroadcast();
} }
}
} }
}, intentFilter); }, intentFilter);
} }
......
package com.evollu.react.fcm; package com.evollu.react.firebase;
import android.content.Intent;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
...@@ -12,9 +10,9 @@ import java.util.Arrays; ...@@ -12,9 +10,9 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class FCMPackage implements ReactPackage { public class FIRMessagingPackage implements ReactPackage {
public FCMPackage() { public FIRMessagingPackage() {
} }
@Override @Override
...@@ -22,7 +20,7 @@ public class FCMPackage implements ReactPackage { ...@@ -22,7 +20,7 @@ public class FCMPackage implements ReactPackage {
ReactApplicationContext reactContext) { ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>(); List<NativeModule> modules = new ArrayList<>();
modules.add(new FCMModule(reactContext, null)); modules.add(new FIRMessagingModule(reactContext));
return modules; return modules;
} }
......
package com.evollu.react.fcm; package com.evollu.react.firebase;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
...@@ -25,7 +25,7 @@ public class InstanceIdService extends FirebaseInstanceIdService { ...@@ -25,7 +25,7 @@ public class InstanceIdService extends FirebaseInstanceIdService {
// Broadcast refreshed token // Broadcast refreshed token
Intent i = new Intent("com.evollu.react.fcm.FCMRefreshToken"); Intent i = new Intent("com.evollu.react.firebase.FCMRefreshToken");
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("token", refreshedToken); bundle.putString("token", refreshedToken);
i.putExtras(bundle); i.putExtras(bundle);
......
package com.evollu.react.fcm; package com.evollu.react.firebase;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
...@@ -14,10 +14,8 @@ public class MessagingService extends FirebaseMessagingService { ...@@ -14,10 +14,8 @@ public class MessagingService extends FirebaseMessagingService {
@Override @Override
public void onMessageReceived(RemoteMessage remoteMessage) { public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "Remote message received"); Log.d(TAG, "Remote message received");
Intent i = new Intent("com.evollu.fcm.ReceiveNotification"); Intent i = new Intent("com.evollu.react.firebase.ReceiveNotification");
if(remoteMessage.getData() != null){ i.putExtra("data", remoteMessage);
i.putExtra("data", new JSONObject(remoteMessage.getData()).toString());
sendOrderedBroadcast(i, null); sendOrderedBroadcast(i, null);
} }
}
} }
'use strict'; 'use strict';
var React = require('react-native'); var React = require('react-native');
var { var {NativeModules} = React;
NativeModules
} = React;
var FCMModule = NativeModules.FCMModule; var FIRMessaging = NativeModules.RNFIRMessaging;
console.log(NativeModules.RNFIRMessaging);
class FCM { class FCM {
static getFCMToken() { static getFCMToken() {
return FCMModule.getFCMToken(); return FIRMessaging.getFCMToken();
} }
static requestPermissions() { static requestPermissions() {
return FCMModule.requestPermissions(); return FIRMessaging.requestPermissions();
} }
constructor(data) {
this.data = data;
}
} }
module.exports = FCM; module.exports = FCM;
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
extern NSString *const FCMNotificationReceived; extern NSString *const FCMNotificationReceived;
@interface FCMModule : NSObject <RCTBridgeModule> @interface RNFIRMessaging : NSObject <RCTBridgeModule>
@property (nonatomic, assign) bool connectedToFCM; @property (nonatomic, assign) bool connectedToFCM;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
3AD1DC2B1CFA802F008C092E /* FCMModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AD1DC2A1CFA802F008C092E /* FCMModule.m */; }; 3AD1DC2B1CFA802F008C092E /* RNFIRMesssaging.m in Sources */ = {isa = PBXBuildFile; fileRef = 3AD1DC2A1CFA802F008C092E /* RNFIRMesssaging.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
134814201AA4EA6300B7C361 /* libRNFCM.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNFCM.a; sourceTree = BUILT_PRODUCTS_DIR; }; 134814201AA4EA6300B7C361 /* libRNFIRMessaging.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNFIRMessaging.a; sourceTree = BUILT_PRODUCTS_DIR; };
3AD1DC291CFA802F008C092E /* FCMModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FCMModule.h; sourceTree = "<group>"; }; 3AD1DC291CFA802F008C092E /* RNFIRMessaging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFIRMessaging.h; sourceTree = "<group>"; };
3AD1DC2A1CFA802F008C092E /* FCMModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FCMModule.m; sourceTree = "<group>"; }; 3AD1DC2A1CFA802F008C092E /* RNFIRMesssaging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFIRMesssaging.m; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
134814211AA4EA7D00B7C361 /* Products */ = { 134814211AA4EA7D00B7C361 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
134814201AA4EA6300B7C361 /* libRNFCM.a */, 134814201AA4EA6300B7C361 /* libRNFIRMessaging.a */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
58B511D21A9E6C8500147676 = { 58B511D21A9E6C8500147676 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3AD1DC291CFA802F008C092E /* FCMModule.h */, 3AD1DC291CFA802F008C092E /* RNFIRMessaging.h */,
3AD1DC2A1CFA802F008C092E /* FCMModule.m */, 3AD1DC2A1CFA802F008C092E /* RNFIRMesssaging.m */,
134814211AA4EA7D00B7C361 /* Products */, 134814211AA4EA7D00B7C361 /* Products */,
); );
indentWidth = 2; indentWidth = 2;
...@@ -61,9 +61,9 @@ ...@@ -61,9 +61,9 @@
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
58B511DA1A9E6C8500147676 /* RNFCM */ = { 58B511DA1A9E6C8500147676 /* RNFIRMessaging */ = {
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNFCM" */; buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNFIRMessaging" */;
buildPhases = ( buildPhases = (
58B511D71A9E6C8500147676 /* Sources */, 58B511D71A9E6C8500147676 /* Sources */,
58B511D81A9E6C8500147676 /* Frameworks */, 58B511D81A9E6C8500147676 /* Frameworks */,
...@@ -73,9 +73,9 @@ ...@@ -73,9 +73,9 @@
); );
dependencies = ( dependencies = (
); );
name = RNFCM; name = RNFIRMessaging;
productName = RCTDataManager; productName = RCTDataManager;
productReference = 134814201AA4EA6300B7C361 /* libRNFCM.a */; productReference = 134814201AA4EA6300B7C361 /* libRNFIRMessaging.a */;
productType = "com.apple.product-type.library.static"; productType = "com.apple.product-type.library.static";
}; };
/* End PBXNativeTarget section */ /* End PBXNativeTarget section */
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
}; };
}; };
}; };
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNFCM" */; buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNFIRMessaging" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = English;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
projectDirPath = ""; projectDirPath = "";
projectRoot = ""; projectRoot = "";
targets = ( targets = (
58B511DA1A9E6C8500147676 /* RNFCM */, 58B511DA1A9E6C8500147676 /* RNFIRMessaging */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
3AD1DC2B1CFA802F008C092E /* FCMModule.m in Sources */, 3AD1DC2B1CFA802F008C092E /* RNFIRMesssaging.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
); );
LIBRARY_SEARCH_PATHS = "$(inherited)"; LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RNFCM; PRODUCT_NAME = RNFIRMessaging;
RUN_CLANG_STATIC_ANALYZER = YES; RUN_CLANG_STATIC_ANALYZER = YES;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
}; };
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
); );
LIBRARY_SEARCH_PATHS = "$(inherited)"; LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = RNFCM; PRODUCT_NAME = RNFIRMessaging;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
}; };
name = Release; name = Release;
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
/* End XCBuildConfiguration section */ /* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */ /* Begin XCConfigurationList section */
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNFCM" */ = { 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNFIRMessaging" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
58B511ED1A9E6C8500147676 /* Debug */, 58B511ED1A9E6C8500147676 /* Debug */,
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNFCM" */ = { 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNFIRMessaging" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (
58B511F01A9E6C8500147676 /* Debug */, 58B511F01A9E6C8500147676 /* Debug */,
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "58B511DA1A9E6C8500147676" BlueprintIdentifier = "58B511DA1A9E6C8500147676"
BuildableName = "libRNFCM.a" BuildableName = "libRNFIRMessaging.a"
BlueprintName = "RNFCM" BlueprintName = "RNFIRMessaging"
ReferencedContainer = "container:RNFCM.xcodeproj"> ReferencedContainer = "container:RNFIRMessaging.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
</BuildActionEntries> </BuildActionEntries>
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "58B511DA1A9E6C8500147676" BlueprintIdentifier = "58B511DA1A9E6C8500147676"
BuildableName = "libRNFCM.a" BuildableName = "libRNFIRMessaging.a"
BlueprintName = "RNFCM" BlueprintName = "RNFIRMessaging"
ReferencedContainer = "container:RNFCM.xcodeproj"> ReferencedContainer = "container:RNFIRMessaging.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions> <AdditionalOptions>
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "58B511DA1A9E6C8500147676" BlueprintIdentifier = "58B511DA1A9E6C8500147676"
BuildableName = "libRNFCM.a" BuildableName = "libRNFIRMessaging.a"
BlueprintName = "RNFCM" BlueprintName = "RNFIRMessaging"
ReferencedContainer = "container:RNFCM.xcodeproj"> ReferencedContainer = "container:RNFIRMessaging.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions> <AdditionalOptions>
...@@ -73,9 +73,9 @@ ...@@ -73,9 +73,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "58B511DA1A9E6C8500147676" BlueprintIdentifier = "58B511DA1A9E6C8500147676"
BuildableName = "libRNFCM.a" BuildableName = "libRNFIRMessaging.a"
BlueprintName = "RNFCM" BlueprintName = "RNFIRMessaging"
ReferencedContainer = "container:RNFCM.xcodeproj"> ReferencedContainer = "container:RNFIRMessaging.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
</ProfileAction> </ProfileAction>
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
<dict> <dict>
<key>SchemeUserState</key> <key>SchemeUserState</key>
<dict> <dict>
<key>RNFCM.xcscheme</key> <key>RNFIRMessaging.xcscheme</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>19</integer> <integer>20</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
......
#import "FCMModule.h" #import "RNFIRMessaging.h"
#import "RCTBridge.h" #import "RCTBridge.h"
#import "RCTConvert.h" #import "RCTConvert.h"
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
NSString *const FCMNotificationReceived = @"FCMNotificationReceived"; NSString *const FCMNotificationReceived = @"FCMNotificationReceived";
@implementation FCMModule @implementation RNFIRMessaging
RCT_EXPORT_MODULE() RCT_EXPORT_MODULE()
......
{ {
"_args": [
[
"react-native-fcm@git://github.com/evollu/react-native-fcm.git",
"/Users/LLu/Code/Patient/client"
]
],
"_from": "git://github.com/evollu/react-native-fcm.git",
"_id": "react-native-fcm@1.0.2",
"_inCache": true,
"_installable": true,
"_location": "/react-native-fcm",
"_phantomChildren": {},
"_requested": {
"hosted": {
"directUrl": "https://raw.githubusercontent.com/evollu/react-native-fcm/master/package.json",
"gitUrl": "git://github.com/evollu/react-native-fcm.git",
"httpsUrl": "git+https://github.com/evollu/react-native-fcm.git",
"shortcut": "github:evollu/react-native-fcm",
"ssh": "git@github.com:evollu/react-native-fcm.git",
"sshUrl": "git+ssh://git@github.com/evollu/react-native-fcm.git",
"type": "github"
},
"name": "react-native-fcm", "name": "react-native-fcm",
"version": "1.0.3", "raw": "react-native-fcm@git://github.com/evollu/react-native-fcm.git",
"description": "React Native component for FCM for IOS and Android", "rawSpec": "git://github.com/evollu/react-native-fcm.git",
"repository": { "scope": null,
"type": "git", "spec": "git://github.com/evollu/react-native-fcm.git",
"url": "git+https://github.com/evollu/react-native-fcm.git" "type": "hosted"
},
"_requiredBy": [
"/"
],
"_resolved": "git://github.com/evollu/react-native-fcm.git#2ae6dfedcff3fea6afdae2d7f971d0f9e0dd2930",
"_shasum": "7669d2f1dfd25247edc26a29d69927faf1c43634",
"_shrinkwrap": null,
"_spec": "react-native-fcm@git://github.com/evollu/react-native-fcm.git",
"_where": "/Users/LLu/Code/Patient/client",
"author": {
"name": "Libin Lu"
},
"bugs": {
"url": "https://github.com/evollu/react-native-fcm/issues"
}, },
"dependencies": {},
"description": "React Native component for FCM for IOS and Android",
"devDependencies": {},
"gitHead": "2ae6dfedcff3fea6afdae2d7f971d0f9e0dd2930",
"homepage": "https://github.com/evollu/react-native-fcm",
"keywords": [ "keywords": [
"React-Native", "React-Native",
"ios", "ios",
...@@ -14,10 +55,14 @@ ...@@ -14,10 +55,14 @@
"firebase", "firebase",
"cloud messaging" "cloud messaging"
], ],
"author": "Libin Lu",
"license": "MIT", "license": "MIT",
"bugs": { "name": "react-native-fcm",
"url": "https://github.com/evollu/react-native-fcm/issues" "optionalDependencies": {},
"readme": "# react-native-gcm-push-notification\n\nFirebase notification for React Native Android and IOS\n\n## Demo\n\nhttps://github.com/oney/TestGcm\n\n## Installation\n\n- Run `npm install react-native-fcm --save`\n- Run rnpm link\n\n## Android Configuration\n\n- In `android/build.gradle`\n```gradle\ndependencies {\nclasspath 'com.android.tools.build:gradle:2.0.0'\nclasspath 'com.google.gms:google-services:3.0.0' // <- Add this line\n```\n\n- In `android/app/build.gradle`\n```gradle\napply plugin: \"com.android.application\"\napply plugin: 'com.google.gms.google-services' // <- Add this line\n...\n```\n\n- In `android/app/src/main/AndroidManifest.xml`, add these lines, be sure to change `com.xxx.yyy` to your package\n\n```\n<application\nandroid:theme=\"@style/AppTheme\">\n\n...\n<service android:name=\"com.evollu.react.fcm.MessagingService\">\n<intent-filter>\n<action android:name=\"com.google.firebase.MESSAGING_EVENT\"/>\n</intent-filter>\n</service>\n\n<service android:name=\"com.evollu.react.fcm.InstanceIdService\" android:exported=\"false\">\n<intent-filter>\n<action android:name=\"com.google.firebase.INSTANCE_ID_EVENT\"/>\n</intent-filter>\n</service>\n...\n```\n\n### IOS Configuration\n\ninstall pod 'Firebase/Messaging'\n\nin AppDelegate.m add\n```\n#import \"FCMModule.h\"\n...\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n....\n[FIRApp configure]; <-- add this line\n}\n\n//add this\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification {\n[[NSNotificationCenter defaultCenter] postNotificationName: FCMNotificationReceived\nobject:self\nuserInfo:notification];\n\n}\n\n//add this\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler {\n[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived\nobject:self\nuserInfo:notification];\nhandler(UIBackgroundFetchResultNoData);\n}\n```\n\n\n### FCM config file\nIn [firebase console](https://console.firebase.google.com/), you can get `google-services.json` file and place it in `android/app` directory and get `googleServices-info.plist` file and place it in `/ios` directory\n\n### Usage\n\n```javascript\n\nvar FCM = require('react-native-fcm');\n\ncomponentWillMount() {\nFCM.requestPermissions();\nFCM.getFCMToken().then(token => {\n//store fcm token in your server\n});\nthis.fcmNotifLsnr = DeviceEventEmitter.addListener('FCMNotificationReceived', (notif) => {\n//there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload\n});\nthis.fcmTokenLsnr = DeviceEventEmitter.addListener('FCMTokenRefreshed', (token) => {\n//fcm token may not be available on first load, catch it here\n});\n}\n\ncomponentWillUnmount() {\n//prevent leak\nthis.fcmNotifLsnr.remove();\nthis.fcmTokenLsnr.remove();\n}\n\n}\n```\n\n## Q & A\n### My android build is failing\nTry update your SDK and google play service\n### I can't get data notification when app is killed?\nIf you send notification with payload only, you can only get the data message when app is in foreground or background. Killed app can't show notification\n### Why I don't get data notification when I'm sending hybrid notification when app is in background?\nI want to figure it out too. Looks like that is how GCM/FCM works. I'm sending 2 notification separately for now. Let me know if you find a better solution\n\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/evollu/react-native-fcm.git"
}, },
"homepage": "https://github.com/evollu/react-native-fcm" "version": "1.0.2"
} }
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