diff --git a/example/.buckconfig b/example/.buckconfig new file mode 100644 index 0000000000000000000000000000000000000000..934256cb29d4a3616c740861c6af35ff6a165917 --- /dev/null +++ b/example/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/example/.flowconfig b/example/.flowconfig new file mode 100644 index 0000000000000000000000000000000000000000..f56848d2fe86a45e3e5430535eed37a4715bc69a --- /dev/null +++ b/example/.flowconfig @@ -0,0 +1,96 @@ +[ignore] + +# We fork some components by platform. +.*/*.web.js +.*/*.android.js + +# Some modules have their own node_modules with overlap +.*/node_modules/node-haste/.* + +# Ugh +.*/node_modules/babel.* +.*/node_modules/babylon.* +.*/node_modules/invariant.* + +# Ignore react and fbjs where there are overlaps, but don't ignore +# anything that react-native relies on +.*/node_modules/fbjs/lib/Map.js +.*/node_modules/fbjs/lib/fetch.js +.*/node_modules/fbjs/lib/ExecutionEnvironment.js +.*/node_modules/fbjs/lib/ErrorUtils.js + +# Flow has a built-in definition for the 'react' module which we prefer to use +# over the currently-untyped source +.*/node_modules/react/react.js +.*/node_modules/react/lib/React.js +.*/node_modules/react/lib/ReactDOM.js + +.*/__mocks__/.* +.*/__tests__/.* + +.*/commoner/test/source/widget/share.js + +# Ignore commoner tests +.*/node_modules/commoner/test/.* + +# See https://github.com/facebook/flow/issues/442 +.*/react-tools/node_modules/commoner/lib/reader.js + +# Ignore jest +.*/node_modules/jest-cli/.* + +# Ignore Website +.*/website/.* + +# Ignore generators +.*/local-cli/generator.* + +# Ignore BUCK generated folders +.*\.buckd/ + +.*/node_modules/is-my-json-valid/test/.*\.json +.*/node_modules/iconv-lite/encodings/tables/.*\.json +.*/node_modules/y18n/test/.*\.json +.*/node_modules/spdx-license-ids/spdx-license-ids.json +.*/node_modules/spdx-exceptions/index.json +.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json +.*/node_modules/resolve/lib/core.json +.*/node_modules/jsonparse/samplejson/.*\.json +.*/node_modules/json5/test/.*\.json +.*/node_modules/ua-parser-js/test/.*\.json +.*/node_modules/builtin-modules/builtin-modules.json +.*/node_modules/binary-extensions/binary-extensions.json +.*/node_modules/url-regex/tlds.json +.*/node_modules/joi/.*\.json +.*/node_modules/isemail/.*\.json +.*/node_modules/tr46/.*\.json + + +[include] + +[libs] +node_modules/react-native/Libraries/react-native/react-native-interface.js +node_modules/react-native/flow +flow/ + +[options] +module.system=haste + +esproposal.class_static_fields=enable +esproposal.class_instance_fields=enable + +munge_underscores=true + +module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' +module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub' + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FixMe + +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy + +[version] +0.23.0 diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..42c9490e508a089affa5e8fe2a5064dc5affdc53 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,40 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IJ +# +.idea +.gradle +local.properties + +# node.js +# +node_modules/ +npm-debug.log + +# BUCK +buck-out/ +\.buckd/ +android/app/libs +android/keystores/debug.keystore diff --git a/example/.watchmanconfig b/example/.watchmanconfig new file mode 100644 index 0000000000000000000000000000000000000000..9e26dfeeb6e641a33dae4961196235bdb965b21b --- /dev/null +++ b/example/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/example/android/app/BUCK b/example/android/app/BUCK new file mode 100644 index 0000000000000000000000000000000000000000..68d3f1fdfe479fb7f473c422803f5137c574ea6e --- /dev/null +++ b/example/android/app/BUCK @@ -0,0 +1,66 @@ +import re + +# To learn about Buck see [Docs](https://buckbuild.com/). +# To run your application with Buck: +# - install Buck +# - `npm start` - to start the packager +# - `cd android` +# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US` +# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck +# - `buck install -r android/app` - compile, install and run application +# + +lib_deps = [] +for jarfile in glob(['libs/*.jar']): + name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) + lib_deps.append(':' + name) + prebuilt_jar( + name = name, + binary_jar = jarfile, + ) + +for aarfile in glob(['libs/*.aar']): + name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) + lib_deps.append(':' + name) + android_prebuilt_aar( + name = name, + aar = aarfile, + ) + +android_library( + name = 'all-libs', + exported_deps = lib_deps +) + +android_library( + name = 'app-code', + srcs = glob([ + 'src/main/java/**/*.java', + ]), + deps = [ + ':all-libs', + ':build_config', + ':res', + ], +) + +android_build_config( + name = 'build_config', + package = 'com.notificationsexampleapp', +) + +android_resource( + name = 'res', + res = 'src/main/res', + package = 'com.notificationsexampleapp', +) + +android_binary( + name = 'app', + package_type = 'debug', + manifest = 'src/main/AndroidManifest.xml', + keystore = '//android/keystores:debug', + deps = [ + ':app-code', + ], +) diff --git a/example/android/app/src/main/java/com/notificationsexampleapp/MainActivity.java b/example/android/app/src/main/java/com/notificationsexampleapp/MainActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..5a219d44e0c5785ff291a8dca53eb1046402e151 --- /dev/null +++ b/example/android/app/src/main/java/com/notificationsexampleapp/MainActivity.java @@ -0,0 +1,40 @@ +package com.notificationsexampleapp; + +import com.facebook.react.ReactActivity; +import com.facebook.react.ReactPackage; +import com.facebook.react.shell.MainReactPackage; + +import java.util.Arrays; +import java.util.List; + +public class MainActivity extends ReactActivity { + + /** + * Returns the name of the main component registered from JavaScript. + * This is used to schedule rendering of the component. + */ + @Override + protected String getMainComponentName() { + return "NotificationsExampleApp"; + } + + /** + * Returns whether dev mode should be enabled. + * This enables e.g. the dev menu. + */ + @Override + protected boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; + } + + /** + * A list of packages used by the app. If the app uses additional views + * or modules besides the default ones, add more packages here. + */ + @Override + protected List getPackages() { + return Arrays.asList( + new MainReactPackage() + ); + } +} diff --git a/example/index.android.js b/example/index.android.js index f3659067e73b6550212971ab374622a7b198b1bf..893f30a359943fed705e980b2b27c5975ac9fb50 100644 --- a/example/index.android.js +++ b/example/index.android.js @@ -3,13 +3,13 @@ * https://github.com/facebook/react-native */ -import React, { +import { AppRegistry, - Component, StyleSheet, Text, View } from 'react-native'; +import React, {Component} from 'react'; class NotificationsExampleApp extends Component { render() { diff --git a/example/index.ios.js b/example/index.ios.js index c36a503c50127f898e5733e7673a268206b04c7e..333f57ea329407b7d9d0adcb9f37d16239a6f30e 100644 --- a/example/index.ios.js +++ b/example/index.ios.js @@ -3,13 +3,13 @@ * https://github.com/facebook/react-native */ -import React, { +import { AppRegistry, - Component, StyleSheet, Text, View } from 'react-native'; +import React, {Component} from 'react'; import NotificationsIOS, { NotificationAction, NotificationCategory } from 'react-native-notifications'; diff --git a/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj b/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj index 0817c65e7530b2d74177aa203e87b4d66e0cdc34..583643eb4bda13fdeaff2c168e9a802550e54cbb 100644 --- a/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj +++ b/example/ios/NotificationsExampleApp.xcodeproj/project.pbxproj @@ -688,7 +688,10 @@ ); INFOPLIST_FILE = NotificationsExampleApp/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.wix.smart-notifications-test-app"; PRODUCT_NAME = NotificationsExampleApp; PROVISIONING_PROFILE = ""; @@ -708,7 +711,10 @@ ); INFOPLIST_FILE = NotificationsExampleApp/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.wix.smart-notifications-test-app"; PRODUCT_NAME = NotificationsExampleApp; PROVISIONING_PROFILE = ""; diff --git a/example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp.xcscheme b/example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..927b1bb796f4c95586eb257bf0255b2fd7ae2f81 --- /dev/null +++ b/example/ios/NotificationsExampleApp.xcodeproj/xcshareddata/xcschemes/NotificationsExampleApp.xcscheme @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/NotificationsExampleAppTests/NotificationsExampleAppTests.m b/example/ios/NotificationsExampleAppTests/NotificationsExampleAppTests.m new file mode 100644 index 0000000000000000000000000000000000000000..fa7a160235861070b97252907ce33b312f3d1bdc --- /dev/null +++ b/example/ios/NotificationsExampleAppTests/NotificationsExampleAppTests.m @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import +#import + +#import "RCTLog.h" +#import "RCTRootView.h" + +#define TIMEOUT_SECONDS 600 +#define TEXT_TO_LOOK_FOR @"Welcome to React Native!" + +@interface NotificationsExampleAppTests : XCTestCase + +@end + +@implementation NotificationsExampleAppTests + +- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test +{ + if (test(view)) { + return YES; + } + for (UIView *subview in [view subviews]) { + if ([self findSubviewInView:subview matching:test]) { + return YES; + } + } + return NO; +} + +- (void)testRendersWelcomeScreen +{ + UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; + BOOL foundElement = NO; + + __block NSString *redboxError = nil; + RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { + if (level >= RCTLogLevelError) { + redboxError = message; + } + }); + + while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { + [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; + + foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { + if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { + return YES; + } + return NO; + }]; + } + + RCTSetLogFunction(RCTDefaultLogFunction); + + XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); + XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); +} + + +@end diff --git a/example/package.json b/example/package.json index 4e00ec349c99384566716cbc10abf5f2e34b1c57..c5a7960fcbf2db0e59d45a22807fdd8bcf053d23 100644 --- a/example/package.json +++ b/example/package.json @@ -8,7 +8,7 @@ "dependencies": { "babel-preset-react-native-stage-0": "^1.0.1", "react": "^0.14.7", - "react-native": "^0.22.2", + "react-native": "^0.25.1", "react-native-notifications": "../" }, "babel": { diff --git a/package.json b/package.json index 8973e59855a8c5f324468d460b5bfaae793cfaa7..219af31d4a1a263fb27b56e0411320527651ff7a 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "core-js": "^1.0.0" }, "peerDependencies": { - "react-native": ">=0.19.0" + "react-native": ">=0.25.1", + "react": "0.14.5" }, "devDependencies": { "babel-eslint": "^6.0.2",