From 736ac7a73b9cf5fec9a74feb5935fd1111746fe5 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Thu, 6 Jul 2017 21:47:22 +0200 Subject: [PATCH 01/94] update example to react-native 0.46 --- Example/.babelrc | 3 + Example/.flowconfig | 34 +- Example/.gitattributes | 1 + Example/.gitignore | 20 +- Example/android/app/build.gradle | 13 +- Example/android/app/proguard-rules.pro | 4 + .../android/app/src/main/AndroidManifest.xml | 3 +- .../java/com/example/MainApplication.java | 15 +- .../app/src/main/res/values/strings.xml | 2 - Example/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- Example/android/keystores/BUCK | 12 +- Example/app.json | 4 + Example/ios/Example.xcodeproj/project.pbxproj | 422 +++++++++++++++--- .../xcshareddata/xcschemes/Example.xcscheme | 27 +- Example/ios/Example/AppDelegate.m | 4 +- .../AppIcon.appiconset/Contents.json | 10 + Example/ios/Example/Info.plist | 4 +- Example/ios/ExampleTests/ExampleTests.m | 6 +- Example/package.json | 16 +- 20 files changed, 497 insertions(+), 107 deletions(-) create mode 100644 Example/.babelrc create mode 100644 Example/.gitattributes create mode 100644 Example/app.json diff --git a/Example/.babelrc b/Example/.babelrc new file mode 100644 index 000000000..a9ce1369e --- /dev/null +++ b/Example/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["react-native"] +} diff --git a/Example/.flowconfig b/Example/.flowconfig index e28e2f5bd..1dd3eff69 100644 --- a/Example/.flowconfig +++ b/Example/.flowconfig @@ -1,13 +1,18 @@ [ignore] +; We fork some components by platform +.*/*[.]android.js -# We fork some components by platform. -.*/*.android.js +; Ignore "BUCK" generated dirs +/\.buckd/ -# Ignore templates with `@flow` in header -.*/local-cli/generator.* +; Ignore unexpected extra "@providesModule" +.*/node_modules/.*/node_modules/fbjs/.* -# Ignore malformed json -.*/node_modules/y18n/test/.*\.json +; Ignore duplicate module providers +; For RN Apps installed via npm, "Libraries" folder is inside +; "node_modules/react-native" but in the source repo it is in the root +.*/Libraries/react-native/React.js +.*/Libraries/react-native/ReactNative.js [include] @@ -17,25 +22,24 @@ node_modules/react-native/flow flow/ [options] -module.system=haste - -esproposal.class_static_fields=enable -esproposal.class_instance_fields=enable +emoji=true -experimental.strict_type_args=true +module.system=haste 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\|pdf\)$' -> 'RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy +suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError + +unsafe.enable_getters_and_setters=true [version] -^0.27.0 +^0.47.0 diff --git a/Example/.gitattributes b/Example/.gitattributes new file mode 100644 index 000000000..d42ff1835 --- /dev/null +++ b/Example/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/Example/.gitignore b/Example/.gitignore index e0117914c..ca38b8bc1 100644 --- a/Example/.gitignore +++ b/Example/.gitignore @@ -23,20 +23,32 @@ DerivedData project.xcworkspace ios/GoogleMobileAds.framework/ -# Android/IJ +# Android/IntelliJ # -*.iml +build/ .idea .gradle local.properties +*.iml # node.js # node_modules/ npm-debug.log +yarn-error.log # BUCK buck-out/ \.buckd/ -android/app/libs -android/keystores/debug.keystore +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots diff --git a/Example/android/app/build.gradle b/Example/android/app/build.gradle index ec538efe9..3ba80e21d 100644 --- a/Example/android/app/build.gradle +++ b/Example/android/app/build.gradle @@ -33,6 +33,13 @@ import com.android.build.OutputFile * // bundleInPaidRelease: true, * // bundleInBeta: true, * + * // whether to disable dev mode in custom build variants (by default only disabled in release) + * // for example: to disable dev mode in the staging build type (if configured) + * devDisabledInStaging: true, + * // The configuration property can be in the following formats + * // 'devDisabledIn${productFlavor}${buildType}' + * // 'devDisabledIn${buildType}' + * * // the root of your project, i.e. where "package.json" lives * root: "../../", * @@ -58,7 +65,7 @@ import com.android.build.OutputFile * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"] + * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] @@ -135,6 +142,6 @@ dependencies { // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { - from configurations.compile - into 'libs' + from configurations.compile + into 'libs' } diff --git a/Example/android/app/proguard-rules.pro b/Example/android/app/proguard-rules.pro index 48361a901..6e8516c8d 100644 --- a/Example/android/app/proguard-rules.pro +++ b/Example/android/app/proguard-rules.pro @@ -50,6 +50,10 @@ -dontwarn com.facebook.react.** +# TextLayoutBuilder uses a non-public Android constructor within StaticLayout. +# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details. +-dontwarn android.text.StaticLayout + # okhttp -keepattributes Signature diff --git a/Example/android/app/src/main/AndroidManifest.xml b/Example/android/app/src/main/AndroidManifest.xml index 677f07596..8275835d5 100644 --- a/Example/android/app/src/main/AndroidManifest.xml +++ b/Example/android/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:configChanges="keyboard|keyboardHidden|orientation|screenSize" + android:windowSoftInputMode="adjustResize"> diff --git a/Example/android/app/src/main/java/com/example/MainApplication.java b/Example/android/app/src/main/java/com/example/MainApplication.java index 30b2acbe2..19c7b5793 100644 --- a/Example/android/app/src/main/java/com/example/MainApplication.java +++ b/Example/android/app/src/main/java/com/example/MainApplication.java @@ -1,14 +1,13 @@ package com.example; import android.app.Application; -import android.util.Log; import com.facebook.react.ReactApplication; import com.sbugert.rnadmob.RNAdMobPackage; -import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; +import com.facebook.soloader.SoLoader; import java.util.Arrays; import java.util.List; @@ -17,7 +16,7 @@ public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override - protected boolean getUseDeveloperSupport() { + public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @@ -25,13 +24,19 @@ protected boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), - new RNAdMobPackage() + new RNAdMobPackage() ); } }; @Override public ReactNativeHost getReactNativeHost() { - return mReactNativeHost; + return mReactNativeHost; + } + + @Override + public void onCreate() { + super.onCreate(); + SoLoader.init(this, /* native exopackage */ false); } } diff --git a/Example/android/app/src/main/res/values/strings.xml b/Example/android/app/src/main/res/values/strings.xml index 603e17737..0057fcb99 100644 --- a/Example/android/app/src/main/res/values/strings.xml +++ b/Example/android/app/src/main/res/values/strings.xml @@ -1,5 +1,3 @@ - - Example diff --git a/Example/android/build.gradle b/Example/android/build.gradle index fcba4c587..eed9972b5 100644 --- a/Example/android/build.gradle +++ b/Example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/Example/android/gradle/wrapper/gradle-wrapper.properties b/Example/android/gradle/wrapper/gradle-wrapper.properties index b9fbfaba0..dbdc05d27 100644 --- a/Example/android/gradle/wrapper/gradle-wrapper.properties +++ b/Example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/Example/android/keystores/BUCK b/Example/android/keystores/BUCK index 15da20e6b..88e4c31b2 100644 --- a/Example/android/keystores/BUCK +++ b/Example/android/keystores/BUCK @@ -1,8 +1,8 @@ keystore( - name = 'debug', - store = 'debug.keystore', - properties = 'debug.keystore.properties', - visibility = [ - 'PUBLIC', - ], + name = "debug", + properties = "debug.keystore.properties", + store = "debug.keystore", + visibility = [ + "PUBLIC", + ], ) diff --git a/Example/app.json b/Example/app.json new file mode 100644 index 000000000..e933d0696 --- /dev/null +++ b/Example/app.json @@ -0,0 +1,4 @@ +{ + "name": "Example", + "displayName": "Example" +} \ No newline at end of file diff --git a/Example/ios/Example.xcodeproj/project.pbxproj b/Example/ios/Example.xcodeproj/project.pbxproj index 98291a482..3a5bb992b 100644 --- a/Example/ios/Example.xcodeproj/project.pbxproj +++ b/Example/ios/Example.xcodeproj/project.pbxproj @@ -22,9 +22,10 @@ 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 62CA481C20E347268E621366 /* libRNAdMobManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9719DB3CDD04BE0B649574F /* libRNAdMobManager.a */; }; + 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; + 5E9FEA541F0EC75500728AA8 /* GoogleMobileAds.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9FEA531F0EC75500728AA8 /* GoogleMobileAds.framework */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; - A9B6E2591D4CD2D0007F56DC /* GoogleMobileAds.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9B6E2581D4CD2D0007F56DC /* GoogleMobileAds.framework */; }; + B87C319A9E6041708B47AAD8 /* libRNAdMobManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 325FF470492B468AAFC9B057 /* libRNAdMobManager.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -91,6 +92,146 @@ remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; remoteInfo = React; }; + 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A283A1D9B042B00D4039D; + remoteInfo = "RCTImage-tvOS"; + }; + 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28471D9B043800D4039D; + remoteInfo = "RCTLinking-tvOS"; + }; + 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28541D9B044C00D4039D; + remoteInfo = "RCTNetwork-tvOS"; + }; + 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28611D9B046600D4039D; + remoteInfo = "RCTSettings-tvOS"; + }; + 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A287B1D9B048500D4039D; + remoteInfo = "RCTText-tvOS"; + }; + 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28881D9B049200D4039D; + remoteInfo = "RCTWebSocket-tvOS"; + }; + 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28131D9B038B00D4039D; + remoteInfo = "React-tvOS"; + }; + 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3C059A1DE3340900C268FA; + remoteInfo = yoga; + }; + 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3C06751DE3340C00C268FA; + remoteInfo = "yoga-tvOS"; + }; + 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; + remoteInfo = cxxreact; + }; + 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; + remoteInfo = "cxxreact-tvOS"; + }; + 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; + remoteInfo = jschelpers; + }; + 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; + remoteInfo = "jschelpers-tvOS"; + }; + 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 134814201AA4EA6300B7C361; + remoteInfo = RCTAnimation; + }; + 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2D2A28201D9B03D100D4039D; + remoteInfo = "RCTAnimation-tvOS"; + }; + 5E9FE9F31F0EC3CF00728AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 139D7ECE1E25DB7D00323FB7; + remoteInfo = "third-party"; + }; + 5E9FE9F51F0EC3CF00728AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D383D3C1EBD27B6005632C8; + remoteInfo = "third-party-tvOS"; + }; + 5E9FE9F71F0EC3CF00728AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 139D7E881E25C6D100323FB7; + remoteInfo = "double-conversion"; + }; + 5E9FE9F91F0EC3CF00728AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3D383D621EBD27B9005632C8; + remoteInfo = "double-conversion-tvOS"; + }; + 5E9FEA261F0EC49400728AA8 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = F3107186DBC94C029D2958EE /* RNAdMobManager.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = A96DA7741C146D7200FC639B; + remoteInfo = RNAdMobManager; + }; 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; @@ -105,13 +246,6 @@ remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteInfo = RCTText; }; - A9B6E2561D4CD2BD007F56DC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = DCD9548BFD464CB7858A5B6E /* RNAdMobManager.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = A96DA7741C146D7200FC639B; - remoteInfo = RNAdMobManager; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -134,11 +268,12 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Example/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Example/main.m; sourceTree = ""; }; 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; + 325FF470492B468AAFC9B057 /* libRNAdMobManager.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNAdMobManager.a; sourceTree = ""; }; + 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; + 5E9FEA531F0EC75500728AA8 /* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GoogleMobileAds.framework; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; - A9B6E2581D4CD2D0007F56DC /* GoogleMobileAds.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GoogleMobileAds.framework; sourceTree = ""; }; - DCD9548BFD464CB7858A5B6E /* RNAdMobManager.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNAdMobManager.xcodeproj; path = "../node_modules/react-native-admob/ios/RNAdMobManager.xcodeproj"; sourceTree = ""; }; - F9719DB3CDD04BE0B649574F /* libRNAdMobManager.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNAdMobManager.a; sourceTree = ""; }; + F3107186DBC94C029D2958EE /* RNAdMobManager.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNAdMobManager.xcodeproj; path = "../node_modules/react-native-admob/ios/RNAdMobManager.xcodeproj"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -155,17 +290,18 @@ buildActionMask = 2147483647; files = ( 146834051AC3E58100842450 /* libReact.a in Frameworks */, + 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */, + 5E9FEA541F0EC75500728AA8 /* GoogleMobileAds.framework in Frameworks */, 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, - A9B6E2591D4CD2D0007F56DC /* GoogleMobileAds.framework in Frameworks */, 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, - 62CA481C20E347268E621366 /* libRNAdMobManager.a in Frameworks */, + B87C319A9E6041708B47AAD8 /* libRNAdMobManager.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -192,6 +328,7 @@ isa = PBXGroup; children = ( 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, + 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */, ); name = Products; sourceTree = ""; @@ -200,6 +337,7 @@ isa = PBXGroup; children = ( 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, + 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */, ); name = Products; sourceTree = ""; @@ -233,6 +371,7 @@ isa = PBXGroup; children = ( 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, + 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */, ); name = Products; sourceTree = ""; @@ -241,6 +380,7 @@ isa = PBXGroup; children = ( 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, + 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */, ); name = Products; sourceTree = ""; @@ -263,14 +403,51 @@ isa = PBXGroup; children = ( 146834041AC3E56700842450 /* libReact.a */, + 3DAD3EA31DF850E9000B6D8A /* libReact.a */, + 3DAD3EA51DF850E9000B6D8A /* libyoga.a */, + 3DAD3EA71DF850E9000B6D8A /* libyoga.a */, + 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */, + 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */, + 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */, + 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */, + 5E9FE9F41F0EC3CF00728AA8 /* libthird-party.a */, + 5E9FE9F61F0EC3CF00728AA8 /* libthird-party.a */, + 5E9FE9F81F0EC3CF00728AA8 /* libdouble-conversion.a */, + 5E9FE9FA1F0EC3CF00728AA8 /* libdouble-conversion.a */, + ); + name = Products; + sourceTree = ""; + }; + 5E91572E1DD0AC6500FF2AA8 /* Products */ = { + isa = PBXGroup; + children = ( + 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */, + 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */, ); name = Products; sourceTree = ""; }; + 5E9FEA061F0EC49400728AA8 /* Products */ = { + isa = PBXGroup; + children = ( + 5E9FEA271F0EC49400728AA8 /* libRNAdMobManager.a */, + ); + name = Products; + sourceTree = ""; + }; + 5E9FEA341F0EC74A00728AA8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5E9FEA531F0EC75500728AA8 /* GoogleMobileAds.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 78C398B11ACF4ADC00677621 /* Products */ = { isa = PBXGroup; children = ( 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, + 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */, ); name = Products; sourceTree = ""; @@ -278,7 +455,7 @@ 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( - A9B6E2581D4CD2D0007F56DC /* GoogleMobileAds.framework */, + 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */, 146833FF1AC3E56700842450 /* React.xcodeproj */, 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, @@ -289,7 +466,7 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, - DCD9548BFD464CB7858A5B6E /* RNAdMobManager.xcodeproj */, + F3107186DBC94C029D2958EE /* RNAdMobManager.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -298,6 +475,7 @@ isa = PBXGroup; children = ( 832341B51AAA6A8300B99B32 /* libRCTText.a */, + 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */, ); name = Products; sourceTree = ""; @@ -305,6 +483,7 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( + 5E9FEA341F0EC74A00728AA8 /* Frameworks */, 13B07FAE1A68108700A75B9A /* Example */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 00E356EF1AD99517003FC87E /* ExampleTests */, @@ -323,14 +502,6 @@ name = Products; sourceTree = ""; }; - A9B6E2491D4CD2BC007F56DC /* Products */ = { - isa = PBXGroup; - children = ( - A9B6E2571D4CD2BD007F56DC /* libRNAdMobManager.a */, - ); - name = Products; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -376,7 +547,7 @@ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 610; + LastUpgradeCheck = 0610; ORGANIZATIONNAME = Facebook; TargetAttributes = { 00E356ED1AD99517003FC87E = { @@ -401,6 +572,10 @@ ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; }, + { + ProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */; + ProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; + }, { ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; @@ -438,8 +613,8 @@ ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, { - ProductGroup = A9B6E2491D4CD2BC007F56DC /* Products */; - ProjectRef = DCD9548BFD464CB7858A5B6E /* RNAdMobManager.xcodeproj */; + ProductGroup = 5E9FEA061F0EC49400728AA8 /* Products */; + ProjectRef = F3107186DBC94C029D2958EE /* RNAdMobManager.xcodeproj */; }, ); projectRoot = ""; @@ -507,6 +682,146 @@ remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRCTImage-tvOS.a"; + remoteRef = 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRCTLinking-tvOS.a"; + remoteRef = 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRCTNetwork-tvOS.a"; + remoteRef = 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRCTSettings-tvOS.a"; + remoteRef = 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRCTText-tvOS.a"; + remoteRef = 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRCTWebSocket-tvOS.a"; + remoteRef = 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EA31DF850E9000B6D8A /* libReact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libReact.a; + remoteRef = 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EA51DF850E9000B6D8A /* libyoga.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libyoga.a; + remoteRef = 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EA71DF850E9000B6D8A /* libyoga.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libyoga.a; + remoteRef = 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcxxreact.a; + remoteRef = 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcxxreact.a; + remoteRef = 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libjschelpers.a; + remoteRef = 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libjschelpers.a; + remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRCTAnimation.a; + remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRCTAnimation.a; + remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9FE9F41F0EC3CF00728AA8 /* libthird-party.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libthird-party.a"; + remoteRef = 5E9FE9F31F0EC3CF00728AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9FE9F61F0EC3CF00728AA8 /* libthird-party.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libthird-party.a"; + remoteRef = 5E9FE9F51F0EC3CF00728AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9FE9F81F0EC3CF00728AA8 /* libdouble-conversion.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libdouble-conversion.a"; + remoteRef = 5E9FE9F71F0EC3CF00728AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9FE9FA1F0EC3CF00728AA8 /* libdouble-conversion.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libdouble-conversion.a"; + remoteRef = 5E9FE9F91F0EC3CF00728AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 5E9FEA271F0EC49400728AA8 /* libRNAdMobManager.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRNAdMobManager.a; + remoteRef = 5E9FEA261F0EC49400728AA8 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -521,13 +836,6 @@ remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - A9B6E2571D4CD2BD007F56DC /* libRNAdMobManager.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRNAdMobManager.a; - remoteRef = A9B6E2561D4CD2BD007F56DC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -562,7 +870,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; }; /* End PBXShellScriptBuildPhase section */ @@ -615,13 +923,21 @@ "DEBUG=1", "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-admob/ios/**", + ); INFOPLIST_FILE = ExampleTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", ); + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + ); PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; @@ -632,13 +948,21 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-admob/ios/**", + ); INFOPLIST_FILE = ExampleTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/$(TARGET_NAME)\"", ); + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + ); PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; @@ -648,6 +972,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -655,8 +980,6 @@ ); HEADER_SEARCH_PATHS = ( "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native-admob/ios/**", ); INFOPLIST_FILE = Example/Info.plist; @@ -667,6 +990,7 @@ "-lc++", ); PRODUCT_NAME = Example; + VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; }; @@ -674,14 +998,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = 1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", ); HEADER_SEARCH_PATHS = ( "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native-admob/ios/**", ); INFOPLIST_FILE = Example/Info.plist; @@ -692,6 +1015,7 @@ "-lc++", ); PRODUCT_NAME = Example; + VERSIONING_SYSTEM = "apple-generic"; }; name = Release; }; @@ -729,13 +1053,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../node_modules/react-native/React/**", - "$(SRCROOT)/../node_modules/react-native-admob/ios/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -770,13 +1088,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../node_modules/react-native/React/**", - "$(SRCROOT)/../node_modules/react-native-admob/ios/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; diff --git a/Example/ios/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Example/ios/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index abcf8a658..273f724d7 100644 --- a/Example/ios/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/Example/ios/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -3,9 +3,23 @@ LastUpgradeVersion = "0620" version = "1.3"> + + + + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +76,18 @@ ReferencedContainer = "container:Example.xcodeproj"> + + @@ -86,10 +103,10 @@ diff --git a/Example/ios/Example/AppDelegate.m b/Example/ios/Example/AppDelegate.m index 9e648fda6..80a9d62be 100644 --- a/Example/ios/Example/AppDelegate.m +++ b/Example/ios/Example/AppDelegate.m @@ -9,8 +9,8 @@ #import "AppDelegate.h" -#import "RCTBundleURLProvider.h" -#import "RCTRootView.h" +#import +#import @implementation AppDelegate diff --git a/Example/ios/Example/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/ios/Example/Images.xcassets/AppIcon.appiconset/Contents.json index 118c98f74..b8236c653 100644 --- a/Example/ios/Example/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/ios/Example/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", diff --git a/Example/ios/Example/Info.plist b/Example/ios/Example/Info.plist index e98ebb004..0bf27a6a6 100644 --- a/Example/ios/Example/Info.plist +++ b/Example/ios/Example/Info.plist @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion en + CFBundleDisplayName + Example CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -45,7 +47,7 @@ localhost - NSTemporaryExceptionAllowsInsecureHTTPLoads + NSExceptionAllowsInsecureHTTPLoads diff --git a/Example/ios/ExampleTests/ExampleTests.m b/Example/ios/ExampleTests/ExampleTests.m index 4130f6187..22ba22506 100644 --- a/Example/ios/ExampleTests/ExampleTests.m +++ b/Example/ios/ExampleTests/ExampleTests.m @@ -10,8 +10,8 @@ #import #import -#import "RCTLog.h" -#import "RCTRootView.h" +#import +#import #define TIMEOUT_SECONDS 600 #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" @@ -37,7 +37,7 @@ - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test - (void)testRendersWelcomeScreen { - UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; BOOL foundElement = NO; diff --git a/Example/package.json b/Example/package.json index ad0ff380a..6fb8c63bd 100644 --- a/Example/package.json +++ b/Example/package.json @@ -3,11 +3,21 @@ "version": "0.0.1", "private": true, "scripts": { - "start": "node node_modules/react-native/local-cli/cli.js start" + "start": "node node_modules/react-native/local-cli/cli.js start", + "test": "jest" }, "dependencies": { - "react": "15.3.1", - "react-native": "^0.33.0", + "react": "16.0.0-alpha.12", + "react-native": "0.46.0", "react-native-admob": "../" + }, + "devDependencies": { + "babel-jest": "20.0.3", + "babel-preset-react-native": "2.1.0", + "jest": "20.0.4", + "react-test-renderer": "16.0.0-alpha.12" + }, + "jest": { + "preset": "react-native" } } From 2986dc46f7d9ffcfaa81795c1eff3f280564a07f Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sun, 9 Jul 2017 18:49:02 +0200 Subject: [PATCH 02/94] reimplement PublisherBanner for iOS please note, these changes are not backwards compatible. The exported view properties now match the properties of the DFPBannerView. I've now implemented the `validAdSizes` property, and replaced the `testDeviceID` property with `testDevices`. Also the simulator device id can be specified using `PublisherBanner.simulatorId` instead of `"EMULATOR"`. The conversion of json to GADAdSize is now implemented using a RCTConvert category. And lastly, the `loadBanner` method is now exposed to react, to allow easy banner refresh, and removes the need of checking which properties are available before making a request to admob. --- RNPublisherBanner.js | 119 ++++++++++---- ios/RCTConvert+GADAdSize.h | 8 + ios/RCTConvert+GADAdSize.m | 32 ++++ ios/RNAdMobDFPManager.m | 29 +++- ios/RNAdMobManager.xcodeproj/project.pbxproj | 6 + ios/RNDFPBannerView.h | 14 +- ios/RNDFPBannerView.m | 162 ++++++++----------- 7 files changed, 227 insertions(+), 143 deletions(-) create mode 100644 ios/RCTConvert+GADAdSize.h create mode 100644 ios/RCTConvert+GADAdSize.m diff --git a/RNPublisherBanner.js b/RNPublisherBanner.js index 1c7d354fb..7bab30747 100644 --- a/RNPublisherBanner.js +++ b/RNPublisherBanner.js @@ -1,52 +1,86 @@ -import React from 'react'; +import React, { Component } from 'react'; import { NativeModules, requireNativeComponent, View, NativeEventEmitter, + Platform, + UIManager, + findNodeHandle, } from 'react-native'; -const RNBanner = requireNativeComponent('RNAdMobDFP', PublisherBanner); - -export default class PublisherBanner extends React.Component { +class PublisherBanner extends Component { constructor() { super(); - this.onSizeChange = this.onSizeChange.bind(this); + this.handleSizeChange = this.handleSizeChange.bind(this); + this.handleAdmobDispatchAppEvent = this.handleAdmobDispatchAppEvent.bind(this); + this.handleDidFailToReceiveAdWithError = this.handleDidFailToReceiveAdWithError.bind(this); this.state = { style: {}, }; } - onSizeChange(event) { + componentDidMount() { + this.loadBanner(); + } + + loadBanner() { + UIManager.dispatchViewManagerCommand( + findNodeHandle(this._bannerView), + UIManager.RNAdMobDFP.Commands.loadBanner, + null, + ); + } + + handleSizeChange(event) { const { height, width } = event.nativeEvent; this.setState({ style: { width, height } }); + if (this.props.onSizeChange) { + this.props.onSizeChange({ width, height }); + } + } + + handleAdmobDispatchAppEvent(event) { + if (this.props.onAdmobDispatchAppEvent) { + const { name, info } = event.nativeEvent; + this.props.onAdmobDispatchAppEvent({ name, info }); + } + } + + handleDidFailToReceiveAdWithError(event) { + if (this.props.onDidFailToReceiveAdWithError) { + this.props.onDidFailToReceiveAdWithError(event.nativeEvent.error); + } } render() { - const { adUnitID, testDeviceID, bannerSize, style, didFailToReceiveAdWithError,admobDispatchAppEvent } = this.props; return ( - - didFailToReceiveAdWithError(event.nativeEvent.error)} - onAdViewWillPresentScreen={this.props.adViewWillPresentScreen} - onAdViewWillDismissScreen={this.props.adViewWillDismissScreen} - onAdViewDidDismissScreen={this.props.adViewDidDismissScreen} - onAdViewWillLeaveApplication={this.props.adViewWillLeaveApplication} - onAdmobDispatchAppEvent={(event) => admobDispatchAppEvent(event)} - testDeviceID={testDeviceID} - adUnitID={adUnitID} - bannerSize={bannerSize} /> - + (this._bannerView = el)} + /> ); } } +PublisherBanner.simulatorId = Platform.OS === 'android' ? 'EMULATOR' : NativeModules.RNAdMobDFPManager.simulatorId; + PublisherBanner.propTypes = { - style: View.propTypes.style, + ...View.propTypes, /** * AdMob iOS library banner size constants @@ -61,7 +95,12 @@ PublisherBanner.propTypes = { * * banner is default */ - bannerSize: React.PropTypes.string, + adSize: React.PropTypes.string, + + /** + * Optional array specifying all valid sizes that are appropriate for this slot. + */ + validAdSizes: React.PropTypes.arrayOf(React.PropTypes.string), /** * AdMob ad unit ID @@ -71,20 +110,30 @@ PublisherBanner.propTypes = { /** * Test device ID */ - testDeviceID: React.PropTypes.string, + testDevices: React.PropTypes.arrayOf(React.PropTypes.string), /** * AdMob iOS library events */ - adViewDidReceiveAd: React.PropTypes.func, - didFailToReceiveAdWithError: React.PropTypes.func, - adViewWillPresentScreen: React.PropTypes.func, - adViewWillDismissScreen: React.PropTypes.func, - adViewDidDismissScreen: React.PropTypes.func, - adViewWillLeaveApplication: React.PropTypes.func, - admobDispatchAppEvent: React.PropTypes.func, - ...View.propTypes, + onSizeChange: React.PropTypes.func, + onAdViewDidReceiveAd: React.PropTypes.func, + onDidFailToReceiveAdWithError: React.PropTypes.func, + onAdViewWillPresentScreen: React.PropTypes.func, + onAdViewWillDismissScreen: React.PropTypes.func, + onAdViewDidDismissScreen: React.PropTypes.func, + onAdViewWillLeaveApplication: React.PropTypes.func, + onAdmobDispatchAppEvent: React.PropTypes.func, +}; + +PublisherBanner.defaultProps = { }; -PublisherBanner.defaultProps = { bannerSize: 'smartBannerPortrait', didFailToReceiveAdWithError: () => {} , -admobDispatchAppEvent: () => {}}; +const RNAdMobDFP = requireNativeComponent('RNAdMobDFP', PublisherBanner, { + nativeOnly: { + onSizeChange: true, + onDidFailToReceiveAdWithError: true, + onAdmobDispatchAppEvent: true, + }, +}); + +export default PublisherBanner; diff --git a/ios/RCTConvert+GADAdSize.h b/ios/RCTConvert+GADAdSize.h new file mode 100644 index 000000000..8cbe378b8 --- /dev/null +++ b/ios/RCTConvert+GADAdSize.h @@ -0,0 +1,8 @@ +#import +@import GoogleMobileAds; + +@interface RCTConvert (GADAdSize) + ++ (GADAdSize)GADAdSize:(id)json; + +@end diff --git a/ios/RCTConvert+GADAdSize.m b/ios/RCTConvert+GADAdSize.m new file mode 100644 index 000000000..61859ba01 --- /dev/null +++ b/ios/RCTConvert+GADAdSize.m @@ -0,0 +1,32 @@ +#import "RCTConvert+GADAdSize.h" + +@implementation RCTConvert (GADAdSize) + ++ (GADAdSize)GADAdSize:(id)json +{ + NSString *adSize = [self NSString:json]; + if ([adSize isEqualToString:@"banner"]) { + return kGADAdSizeBanner; + } else if ([adSize isEqualToString:@"fullBanner"]) { + return kGADAdSizeFullBanner; + } else if ([adSize isEqualToString:@"largeBanner"]) { + return kGADAdSizeLargeBanner; + } else if ([adSize isEqualToString:@"fluid"]) { + return kGADAdSizeFluid; + } else if ([adSize isEqualToString:@"skyscraper"]) { + return kGADAdSizeSkyscraper; + } else if ([adSize isEqualToString:@"leaderboard"]) { + return kGADAdSizeLeaderboard; + } else if ([adSize isEqualToString:@"mediumRectangle"]) { + return kGADAdSizeMediumRectangle; + } else if ([adSize isEqualToString:@"smartBannerPortrait"]) { + return kGADAdSizeSmartBannerPortrait; + } else if ([adSize isEqualToString:@"smartBannerLandscape"]) { + return kGADAdSizeSmartBannerLandscape; + } + else { + return kGADAdSizeInvalid; + } +} + +@end diff --git a/ios/RNAdMobDFPManager.m b/ios/RNAdMobDFPManager.m index e48427eaf..979a6669b 100644 --- a/ios/RNAdMobDFPManager.m +++ b/ios/RNAdMobDFPManager.m @@ -3,16 +3,16 @@ #if __has_include() #import +#import #else #import "RCTBridge.h" +#import "RCTUIManager.h" #endif @implementation RNAdMobDFPManager RCT_EXPORT_MODULE(); -@synthesize bridge = _bridge; - - (UIView *)view { return [[RNDFPBannerView alloc] init]; @@ -23,10 +23,22 @@ - (dispatch_queue_t)methodQueue return dispatch_get_main_queue(); } +RCT_EXPORT_METHOD(loadBanner:(nonnull NSNumber *)reactTag) +{ + [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { + RNDFPBannerView *view = viewRegistry[reactTag]; + if (![view isKindOfClass:[RNDFPBannerView class]]) { + RCTLogError(@"Invalid view returned from registry, expecting RNDFPBannerView, got: %@", view); + } else { + [view loadBanner]; + } + }]; +} -RCT_EXPORT_VIEW_PROPERTY(bannerSize, NSString); -RCT_EXPORT_VIEW_PROPERTY(adUnitID, NSString); -RCT_EXPORT_VIEW_PROPERTY(testDeviceID, NSString); +RCT_EXPORT_VIEW_PROPERTY(adSize, NSString) +RCT_EXPORT_VIEW_PROPERTY(adUnitID, NSString) +RCT_EXPORT_VIEW_PROPERTY(validAdSizes, NSArray) +RCT_EXPORT_VIEW_PROPERTY(testDevices, NSArray) RCT_EXPORT_VIEW_PROPERTY(onSizeChange, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onAdmobDispatchAppEvent, RCTBubblingEventBlock) @@ -37,4 +49,11 @@ - (dispatch_queue_t)methodQueue RCT_EXPORT_VIEW_PROPERTY(onAdViewDidDismissScreen, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onAdViewWillLeaveApplication, RCTBubblingEventBlock) +- (NSDictionary *)constantsToExport +{ + return @{ + @"simulatorId": kGADSimulatorID + }; +} + @end diff --git a/ios/RNAdMobManager.xcodeproj/project.pbxproj b/ios/RNAdMobManager.xcodeproj/project.pbxproj index 3bc6b54c7..033df5c48 100644 --- a/ios/RNAdMobManager.xcodeproj/project.pbxproj +++ b/ios/RNAdMobManager.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 0CB8C04B1D913E00002BC3EF /* RNDFPBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CB8C04A1D913E00002BC3EF /* RNDFPBannerView.m */; }; 0CB8C04E1D9143A6002BC3EF /* RNAdMobDFPManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CB8C04D1D9143A6002BC3EF /* RNAdMobDFPManager.m */; }; + 5E86A6471F126FCE008013EB /* RCTConvert+GADAdSize.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E86A6461F126FCE008013EB /* RCTConvert+GADAdSize.m */; }; A90F2F8C1D50AEF200F2A2E3 /* RNAdMobRewarded.m in Sources */ = {isa = PBXBuildFile; fileRef = A90F2F8B1D50AEF200F2A2E3 /* RNAdMobRewarded.m */; }; A962C2531CB27DBD00E508A1 /* RNAdMobInterstitial.m in Sources */ = {isa = PBXBuildFile; fileRef = A962C2521CB27DBD00E508A1 /* RNAdMobInterstitial.m */; }; A96DA7841C146DA600FC639B /* BannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = A96DA7811C146DA600FC639B /* BannerView.m */; }; @@ -32,6 +33,8 @@ 0CB8C04A1D913E00002BC3EF /* RNDFPBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNDFPBannerView.m; sourceTree = SOURCE_ROOT; }; 0CB8C04C1D9143A6002BC3EF /* RNAdMobDFPManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNAdMobDFPManager.h; sourceTree = SOURCE_ROOT; }; 0CB8C04D1D9143A6002BC3EF /* RNAdMobDFPManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNAdMobDFPManager.m; sourceTree = SOURCE_ROOT; }; + 5E86A6451F126FCE008013EB /* RCTConvert+GADAdSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+GADAdSize.h"; sourceTree = SOURCE_ROOT; }; + 5E86A6461F126FCE008013EB /* RCTConvert+GADAdSize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTConvert+GADAdSize.m"; sourceTree = SOURCE_ROOT; }; A90F2F8A1D50AEF200F2A2E3 /* RNAdMobRewarded.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNAdMobRewarded.h; sourceTree = SOURCE_ROOT; }; A90F2F8B1D50AEF200F2A2E3 /* RNAdMobRewarded.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNAdMobRewarded.m; sourceTree = SOURCE_ROOT; }; A962C2511CB27DBD00E508A1 /* RNAdMobInterstitial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNAdMobInterstitial.h; sourceTree = SOURCE_ROOT; }; @@ -85,6 +88,8 @@ 0CB8C04A1D913E00002BC3EF /* RNDFPBannerView.m */, A90F2F8A1D50AEF200F2A2E3 /* RNAdMobRewarded.h */, A90F2F8B1D50AEF200F2A2E3 /* RNAdMobRewarded.m */, + 5E86A6451F126FCE008013EB /* RCTConvert+GADAdSize.h */, + 5E86A6461F126FCE008013EB /* RCTConvert+GADAdSize.m */, ); path = RNAdMobManager; sourceTree = ""; @@ -151,6 +156,7 @@ A90F2F8C1D50AEF200F2A2E3 /* RNAdMobRewarded.m in Sources */, A96DA7841C146DA600FC639B /* BannerView.m in Sources */, A96DA7851C146DA600FC639B /* RNAdMobManager.m in Sources */, + 5E86A6471F126FCE008013EB /* RCTConvert+GADAdSize.m in Sources */, 0CB8C04E1D9143A6002BC3EF /* RNAdMobDFPManager.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/RNDFPBannerView.h b/ios/RNDFPBannerView.h index 5d2543f90..60da1d6da 100644 --- a/ios/RNDFPBannerView.h +++ b/ios/RNDFPBannerView.h @@ -1,18 +1,19 @@ #if __has_include() -#import +#import #else -#import "RCTComponent.h" +#import "RCTView.h" #endif @import GoogleMobileAds; @class RCTEventDispatcher; -@interface RNDFPBannerView : UIView +@interface RNDFPBannerView : RCTView -@property (nonatomic, copy) NSString *bannerSize; @property (nonatomic, copy) NSString *adUnitID; -@property (nonatomic, copy) NSString *testDeviceID; +@property (nonatomic, copy) NSString *adSize; +@property (nonatomic, copy) NSArray *validAdSizes; +@property (nonatomic, copy) NSArray *testDevices; @property (nonatomic, copy) RCTBubblingEventBlock onSizeChange; @property (nonatomic, copy) RCTBubblingEventBlock onAdmobDispatchAppEvent; @@ -23,8 +24,7 @@ @property (nonatomic, copy) RCTBubblingEventBlock onAdViewDidDismissScreen; @property (nonatomic, copy) RCTBubblingEventBlock onAdViewWillLeaveApplication; -- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; -- (GADAdSize)getAdSizeFromString:(NSString *)bannerSize; +// - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; - (void)loadBanner; @end diff --git a/ios/RNDFPBannerView.m b/ios/RNDFPBannerView.m index 7446c608b..ea6fb1fb1 100644 --- a/ios/RNDFPBannerView.m +++ b/ios/RNDFPBannerView.m @@ -2,136 +2,85 @@ #if __has_include() #import -#import #import #else #import "RCTBridgeModule.h" -#import "UIView+React.h" #import "RCTLog.h" #endif +#include "RCTConvert+GADAdSize.h" + @implementation RNDFPBannerView { DFPBannerView *_bannerView; } -- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex +- (void)dealloc { - RCTLogError(@"AdMob Banner cannot have any subviews"); - return; + _bannerView.delegate = nil; + _bannerView.adSizeDelegate = nil; + _bannerView.appEventDelegate = nil; } -- (void)removeReactSubview:(UIView *)subview +- (instancetype)initWithFrame:(CGRect)frame { - RCTLogError(@"AdMob Banner cannot have any subviews"); - return; -} - -- (GADAdSize)getAdSizeFromString:(NSString *)bannerSize -{ - if ([bannerSize isEqualToString:@"banner"]) { - return kGADAdSizeBanner; - } else if ([bannerSize isEqualToString:@"largeBanner"]) { - return kGADAdSizeLargeBanner; - } else if ([bannerSize isEqualToString:@"mediumRectangle"]) { - return kGADAdSizeMediumRectangle; - } else if ([bannerSize isEqualToString:@"fullBanner"]) { - return kGADAdSizeFullBanner; - } else if ([bannerSize isEqualToString:@"leaderboard"]) { - return kGADAdSizeLeaderboard; - } else if ([bannerSize isEqualToString:@"smartBannerPortrait"]) { - return kGADAdSizeSmartBannerPortrait; - } else if ([bannerSize isEqualToString:@"smartBannerLandscape"]) { - return kGADAdSizeSmartBannerLandscape; - } - else { - return kGADAdSizeBanner; + if ((self = [super initWithFrame:frame])) { + super.backgroundColor = [UIColor clearColor]; + + UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + UIViewController *rootViewController = [keyWindow rootViewController]; + + _bannerView = [[DFPBannerView alloc] initWithAdSize:kGADAdSizeBanner]; + _bannerView.delegate = self; + _bannerView.adSizeDelegate = self; + _bannerView.appEventDelegate = self; + _bannerView.rootViewController = rootViewController; + [self addSubview:_bannerView]; } + + return self; } --(void)loadBanner { - if (_adUnitID && _bannerSize) { - GADAdSize size = [self getAdSizeFromString:_bannerSize]; - _bannerView = [[DFPBannerView alloc] initWithAdSize:size]; - [_bannerView setAppEventDelegate:self]; //added Admob event dispatch listener - if(!CGRectEqualToRect(self.bounds, _bannerView.bounds)) { - if (self.onSizeChange) { - self.onSizeChange(@{ - @"width": [NSNumber numberWithFloat: _bannerView.bounds.size.width], - @"height": [NSNumber numberWithFloat: _bannerView.bounds.size.height] - }); - } - } - _bannerView.delegate = self; - _bannerView.adUnitID = _adUnitID; - _bannerView.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController; - GADRequest *request = [GADRequest request]; - if(_testDeviceID) { - if([_testDeviceID isEqualToString:@"EMULATOR"]) { - request.testDevices = @[kGADSimulatorID]; - } else { - request.testDevices = @[_testDeviceID]; - } - } +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - [_bannerView loadRequest:request]; - } +-(void)loadBanner { + GADRequest *request = [GADRequest request]; + request.testDevices = _testDevices; + [_bannerView loadRequest:request]; } - -- (void)adView:(DFPBannerView *)banner -didReceiveAppEvent:(NSString *)name - withInfo:(NSString *)info { - NSLog(@"Received app event (%@, %@)", name, info); - NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] init]; - myDictionary[name] = info; - if (self.onAdmobDispatchAppEvent) { - self.onAdmobDispatchAppEvent(@{ name: info }); - } +- (void)setAdSize:(NSString *)adSize +{ + _bannerView.adSize = [RCTConvert GADAdSize:adSize]; } -- (void)setBannerSize:(NSString *)bannerSize +- (void)setValidAdSizes:(NSArray *)adSizes { - if(![bannerSize isEqual:_bannerSize]) { - _bannerSize = bannerSize; - if (_bannerView) { - [_bannerView removeFromSuperview]; + NSMutableArray *validAdSizes = [[NSMutableArray alloc] initWithCapacity:adSizes.count]; + [adSizes enumerateObjectsUsingBlock:^(id jsonValue, NSUInteger idx, __unused BOOL *stop) { + GADAdSize adSize = [RCTConvert GADAdSize:jsonValue]; + if (GADAdSizeEqualToSize(adSize, kGADAdSizeInvalid)) { + RCTLogWarn(@"Invalid adSize %@", jsonValue); + } else { + [validAdSizes addObject:NSValueFromGADAdSize(adSize)]; } - [self loadBanner]; - } + }]; + _bannerView.validAdSizes = validAdSizes; } - (void)setAdUnitID:(NSString *)adUnitID { - if(![adUnitID isEqual:_adUnitID]) { - _adUnitID = adUnitID; - if (_bannerView) { - [_bannerView removeFromSuperview]; - } - - [self loadBanner]; - } + _bannerView.adUnitID = adUnitID; } -- (void)setTestDeviceID:(NSString *)testDeviceID + +- (void)setTestDevices:(NSArray *)testDevices { - if(![testDeviceID isEqual:_testDeviceID]) { - _testDeviceID = testDeviceID; - if (_bannerView) { - [_bannerView removeFromSuperview]; - } - [self loadBanner]; - } + _testDevices = testDevices; } -(void)layoutSubviews { - [super layoutSubviews ]; - - _bannerView.frame = CGRectMake( - self.bounds.origin.x, - self.bounds.origin.x, - _bannerView.frame.size.width, - _bannerView.frame.size.height); - [self addSubview:_bannerView]; + [super layoutSubviews]; + _bannerView.frame = self.bounds; } - (void)removeFromSuperview @@ -139,6 +88,8 @@ - (void)removeFromSuperview [super removeFromSuperview]; } +# pragma mark GADBannerViewDelegate + /// Tells the delegate an ad request loaded an ad. - (void)adViewDidReceiveAd:(DFPBannerView *)adView { if (self.onAdViewDidReceiveAd) { @@ -184,4 +135,23 @@ - (void)adViewWillLeaveApplication:(DFPBannerView *)adView { } } +# pragma mark GADAdSizeDelegate + +- (void)adView:(GADBannerView *)bannerView willChangeAdSizeTo:(GADAdSize)size +{ + CGSize adSize = CGSizeFromGADAdSize(size); + self.onSizeChange(@{ + @"width": @(adSize.width), + @"height": @(adSize.height) }); +} + +# pragma mark GADAppEventDelegate + +- (void)adView:(GADBannerView *)banner didReceiveAppEvent:(NSString *)name withInfo:(NSString *)info +{ + if (self.onAdmobDispatchAppEvent) { + self.onAdmobDispatchAppEvent(@{ @"name": name, @"info": info }); + } +} + @end From 86f2f0d6b66e0222a1d7743da1c1e2060aa37a57 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sun, 9 Jul 2017 19:01:42 +0200 Subject: [PATCH 03/94] remove initWithEventDispatcher --- ios/RNDFPBannerView.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ios/RNDFPBannerView.h b/ios/RNDFPBannerView.h index 60da1d6da..430eb1a22 100644 --- a/ios/RNDFPBannerView.h +++ b/ios/RNDFPBannerView.h @@ -24,7 +24,6 @@ @property (nonatomic, copy) RCTBubblingEventBlock onAdViewDidDismissScreen; @property (nonatomic, copy) RCTBubblingEventBlock onAdViewWillLeaveApplication; -// - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER; - (void)loadBanner; @end From 2d548fd3e340f9f5c48e1bece7b597fa63d498ca Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sun, 9 Jul 2017 19:01:59 +0200 Subject: [PATCH 04/94] add examples for multisize and events --- Example/index.ios.js | 75 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/Example/index.ios.js b/Example/index.ios.js index cee6359a3..94a592260 100644 --- a/Example/index.ios.js +++ b/Example/index.ios.js @@ -6,11 +6,27 @@ import { View, Platform, TouchableHighlight, + Button, + ScrollView, } from 'react-native'; -import { AdMobRewarded } from 'react-native-admob'; +import { AdMobRewarded, PublisherBanner } from 'react-native-admob'; + +const BannerExample = ({ style, title, children, ...props }) => ( + + {title} + + {children} + + +); export default class Example extends Component { + constructor() { + super(); + this.state = {}; + } + componentDidMount() { AdMobRewarded.setTestDeviceID('EMULATOR'); AdMobRewarded.setAdUnitID('ca-app-pub-3940256099942544/1033173712'); @@ -51,13 +67,45 @@ export default class Example extends Component { render() { return ( - - - - Show Rewarded Video and preload next - - - + + +