Skip to content

Commit

Permalink
Updated with #226
Browse files Browse the repository at this point in the history
  • Loading branch information
auser committed Feb 5, 2017
2 parents 087c9ca + 4886136 commit 5cc3a6f
Show file tree
Hide file tree
Showing 48 changed files with 1,695 additions and 1,047 deletions.
81 changes: 24 additions & 57 deletions Firestack.podspec
Original file line number Diff line number Diff line change
@@ -1,61 +1,28 @@
require 'json'
package = JSON.parse(File.read('package.json'))
version = package["version"]
repo = package['repository']
author = package['author']

all_pods = [
'FirebaseAnalytics', 'FirebaseAuth', 'FirebaseRemoteConfig',
'FirebaseDatabase', 'FirebaseStorage', 'FirebaseInstanceID',
'GoogleInterchangeUtilities', 'GoogleIPhoneUtilities',
'GoogleNetworkingUtilities', 'GoogleParsingUtilities',
'GoogleSymbolUtilities'
]
package = JSON.parse(File.read('package.json'))

Pod::Spec.new do |s|

s.name = "Firestack"
s.version = version
s.summary = "Firestack makes working with Firebase v3 easy"

s.description = <<-DESC
Wanna integrate firebase into your app using React Native?
DESC

s.homepage = "http://fullstackreact.com"

s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Ari Lerner" => author }
s.social_media_url = 'http://twitter.com/fullstackio'

# When using multiple platforms
s.ios.deployment_target = "8.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"

s.source = { :git => repo['url'], :tag => "v#{version}" }
s.public_header_files = "ios/Firestack/*.h"

s.source_files = 'ios/Firestack/*.{h,m}'
s.preserve_paths = 'README.md', 'package.json', '*.js'

s.ios.frameworks = [
'CFNetwork', 'Security', 'SystemConfiguration'
]
s.ios.libraries = ['icucore', 'c++', 'sqlite3', 'z']

s.xcconfig = {
'HEADER_SEARCH_PATHS' => [
"$(inherited)",
"${SRCROOT}/../../React/**",
"${SRCROOT}/../../node_modules/react-native/**"
].join(' '),
'FRAMEWORK_SEARCH_PATHS' => [
"$(inherited)",
"${PODS_ROOT}/Firebase/**",
"${PODS_ROOT}/FirebaseStorage/**",
].join(' '),
'OTHER_LDFLAGS' => '$(inherited) -ObjC'
}
end
s.name = "Firestack"
s.version = package["version"]
s.summary = package["description"]
s.description = <<-DESC
Wanna integrate firebase into your app using React Native?
DESC
s.homepage = "http://fullstackreact.com"
s.license = package['license']
s.author = "Ari Lerner"
s.source = { :git => "https://github.com/fullstackreact/react-native-firestack.git", :tag => "v#{s.version}" }
s.social_media_url = 'http://twitter.com/fullstackio'
s.platform = :ios, "8.0"
s.header_dir = 'ios/Firestack'
s.preserve_paths = 'README.md', 'package.json', '*.js'
s.source_files = 'ios/Firestack/*.{h,m}'
s.dependency 'React'
s.dependency 'Firebase/Auth'
s.dependency 'Firebase/Core'
s.dependency 'Firebase/Database'
s.dependency 'Firebase/Messaging'
s.dependency 'Firebase/RemoteConfig'
s.dependency 'Firebase/Storage'
end
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ We have a working application example available in at [fullstackreact/FirestackA
* [Events](docs/api/events.md)
* [Redux](docs/redux.md)

## Feature overview
Feature | Firestack | Firebase
------------ | ------------- | -------------
Real time database | -- | YES
Authentication | -- | YES
Cloud messaging | -- | YES
Storage | -- | YES
Crash reporting | -- | YES
Notifications | -- | YES
Remote config | -- | YES
Dynamic links | -- | YES
AdMob | -- | YES
Analytics | -- | YES
App indexing | -- | YES
Hosting | -- | YES
AdWords | -- | YES
Invites | -- | YES

## Contributing

For a detailed discussion of how Firestack works as well as how to contribute, check out our [contribution guide](https://github.com/fullstackreact/react-native-firestack/blob/master/Contributing.md).
12 changes: 12 additions & 0 deletions android/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ allprojects {

dependencies {
compile 'com.facebook.react:react-native:0.20.+'
compile 'com.google.android.gms:play-services-base:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-config:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.google.firebase:firebase-analytics:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-storage:9.8.0'
compile 'com.google.firebase:firebase-messaging:9.8.0'
compile 'com.google.android.gms:play-services-base:+'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-config:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-analytics:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "Remote message received");
// debug
Log.d(TAG, "From: " + remoteMessage.getFrom());

if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}

if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
if (remoteMessage.getNotification() != null) {

}
Intent i = new Intent(FirestackMessaging.INTENT_NAME_NOTIFICATION);
i.putExtra("data", remoteMessage);
sendOrderedBroadcast(i, null);
Expand Down
30 changes: 12 additions & 18 deletions android/src/main/java/io/fullstack/firestack/FirestackModule.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package io.fullstack.firestack;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.HashMap;

import android.util.Log;
import android.content.Context;
import android.support.annotation.Nullable;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReactContext;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
Expand All @@ -32,16 +30,10 @@ interface KeySetterFn {
@SuppressWarnings("WeakerAccess")
public class FirestackModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
private static final String TAG = "Firestack";
private Context context;
private ReactContext mReactContext;
private FirebaseApp app;

public FirestackModule(ReactApplicationContext reactContext, Context context) {
public FirestackModule(ReactApplicationContext reactContext) {
super(reactContext);
this.context = context;
mReactContext = reactContext;

Log.d(TAG, "New instance");
}

@Override
Expand Down Expand Up @@ -69,7 +61,7 @@ public void configureWithOptions(final ReadableMap params, @Nullable final Callb
Log.i(TAG, "configureWithOptions");

FirebaseOptions.Builder builder = new FirebaseOptions.Builder();
FirebaseOptions defaultOptions = FirebaseOptions.fromResource(this.context);
FirebaseOptions defaultOptions = FirebaseOptions.fromResource(getReactApplicationContext().getBaseContext());

if (defaultOptions == null) {
defaultOptions = new FirebaseOptions.Builder().build();
Expand Down Expand Up @@ -154,7 +146,7 @@ public String setKeyOrDefault(
try {
Log.i(TAG, "Configuring app");
if (app == null) {
app = FirebaseApp.initializeApp(this.context, builder.build());
app = FirebaseApp.initializeApp(getReactApplicationContext().getBaseContext(), builder.build());
}
Log.i(TAG, "Configured");

Expand Down Expand Up @@ -189,14 +181,14 @@ public void serverValue(@Nullable final Callback onComplete) {
public void onHostResume() {
WritableMap params = Arguments.createMap();
params.putBoolean("isForground", true);
Utils.sendEvent(mReactContext, "FirestackAppState", params);
Utils.sendEvent(getReactApplicationContext(), "FirestackAppState", params);
}

@Override
public void onHostPause() {
WritableMap params = Arguments.createMap();
params.putBoolean("isForground", false);
Utils.sendEvent(mReactContext, "FirestackAppState", params);
Utils.sendEvent(getReactApplicationContext(), "FirestackAppState", params);
}

@Override
Expand All @@ -208,6 +200,8 @@ public void onHostDestroy() {
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("googleApiAvailability", getPlayServicesStatus());

// TODO remove once this has been moved on ios
constants.put("serverValueTimestamp", ServerValue.TIMESTAMP);
return constants;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public FirestackPackage() {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new FirestackModule(reactContext, reactContext.getBaseContext()));
modules.add(new FirestackModule(reactContext));
modules.add(new FirestackAuth(reactContext));
modules.add(new FirestackDatabase(reactContext));
modules.add(new FirestackAnalytics(reactContext));
Expand Down
9 changes: 7 additions & 2 deletions android/src/main/java/io/fullstack/firestack/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import com.facebook.react.bridge.ReadableType;
Expand Down Expand Up @@ -82,8 +83,12 @@ public static WritableMap dataSnapshotToMap(
data.putString("value", null);
}
} else {
WritableMap valueMap = Utils.castSnapshotValue(dataSnapshot);
data.putMap("value", valueMap);
Object value = Utils.castSnapshotValue(dataSnapshot);
if (value instanceof WritableNativeArray) {
data.putArray("value", (WritableArray) value);
} else {
data.putMap("value", (WritableMap) value);
}
}

// Child keys
Expand Down
Loading

0 comments on commit 5cc3a6f

Please sign in to comment.