diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f9307f..dd6acff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ -## 0.9.0 +## 1.0.0-nullsafety.0 +- Add nullsafety - PR by @RR-Reddy +- Add support for iOSAdvertiserTrackingEnabled flag - default: false +## 0.9.0 - Bumped up Audience Network SDK to v6.3.0 ## 0.8.0 diff --git a/README.md b/README.md index 9725507..cd23221 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ | - | - | | ![Interstitial Ad](https://raw.githubusercontent.com/dreamsoftin/facebook_audience_network/master/example/gifs/interstitial.gif "Interstitial Ad") | ![Rewarded Ad](https://raw.githubusercontent.com/dreamsoftin/facebook_audience_network/master/example/gifs/rewarded.gif "Rewarded Video Ad") | - +--- ## Getting Started ### 1. Initialization: @@ -29,6 +29,7 @@ The hased id will be in printed to the logcat. Paste that onto the `testingId` p ```dart FacebookAudienceNetwork.init( testingId: "37b1da9d-b48c-4103-a393-2e095e734bd6", //optional + iOSAdvertiserTrackingEnabled: true //default false ); ``` ##### IOS Setup @@ -36,6 +37,7 @@ In Pod file, set the IOS deployment target version to 9.0 *IN iOS, Banner, Interstital and Native Ads are supported* +--- ### 2. Show Banner Ad: ```dart @@ -63,7 +65,7 @@ Container( ), ) ``` - +--- ### 3. Show Interstitial Ad: ```dart @@ -75,6 +77,7 @@ FacebookInterstitialAd.loadInterstitialAd( }, ); ``` +--- ### 4. Show Rewarded Video Ad: (Android Only) @@ -89,7 +92,7 @@ FacebookRewardedVideoAd.loadRewardedVideoAd( }, ); ``` - +--- ### 5. Show Native Ad: - NativeAdType NATIVE_AD_HORIZONTAL & NATIVE_AD_VERTICAL ad types are supported only in iOS. In Android use NATIVE_AD. ```dart @@ -112,7 +115,7 @@ FacebookNativeAd( }, ), ``` - +--- ### 6. Show Native Banner Ad: Use `NativeBannerAdSize` to choose the height for Native banner ads. `height` property is ignored for native banner ads. @@ -133,7 +136,7 @@ FacebookNativeAd( }, ), ``` - +--- **Check out the [example](https://github.com/dreamsoftin/facebook_audience_network/tree/master/example) for complete implementation.** iOS wrapper code contribution by **lolqplay team from birdgang** diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 242995b..6267a1b 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,6 +1,4 @@ PODS: - - app_tracking_transparency (0.0.1): - - Flutter - facebook_audience_network (0.0.1): - FBAudienceNetwork (~> 6.3) - Flutter @@ -10,7 +8,6 @@ PODS: - Flutter (1.0.0) DEPENDENCIES: - - app_tracking_transparency (from `.symlinks/plugins/app_tracking_transparency/ios`) - facebook_audience_network (from `.symlinks/plugins/facebook_audience_network/ios`) - Flutter (from `Flutter`) @@ -20,15 +17,12 @@ SPEC REPOS: - FBSDKCoreKit EXTERNAL SOURCES: - app_tracking_transparency: - :path: ".symlinks/plugins/app_tracking_transparency/ios" facebook_audience_network: :path: ".symlinks/plugins/facebook_audience_network/ios" Flutter: :path: Flutter SPEC CHECKSUMS: - app_tracking_transparency: 5b1745ef9ade815f7455cb6a0848349589afb7c5 facebook_audience_network: bb22bdda913d419d8c3247c9570bda4563302417 FBAudienceNetwork: 58b4d0f2359783e5bc9ee59f138b4fda43173ac4 FBSDKCoreKit: fada1a6a0076724678993ff05a633848765ff18c diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 1a146ff..43823fc 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -177,7 +177,7 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = LWNWGSMVRA; + DevelopmentTeam = DDVJA87MT8; LastSwiftMigration = 1130; }; }; @@ -275,12 +275,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${BUILT_PRODUCTS_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework", - "${BUILT_PRODUCTS_DIR}/app_tracking_transparency/app_tracking_transparency.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/app_tracking_transparency.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -379,7 +377,7 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEFINES_MODULE = NO; - DEVELOPMENT_TEAM = LWNWGSMVRA; + DEVELOPMENT_TEAM = DDVJA87MT8; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -392,7 +390,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.rr.interestCalculator; + PRODUCT_BUNDLE_IDENTIFIER = com.dsi.facebookAudienceNetworkExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; @@ -511,7 +509,7 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEFINES_MODULE = NO; - DEVELOPMENT_TEAM = LWNWGSMVRA; + DEVELOPMENT_TEAM = DDVJA87MT8; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -524,7 +522,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.rr.interestCalculator; + PRODUCT_BUNDLE_IDENTIFIER = com.dsi.facebookAudienceNetworkExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; @@ -542,7 +540,7 @@ CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEFINES_MODULE = NO; - DEVELOPMENT_TEAM = LWNWGSMVRA; + DEVELOPMENT_TEAM = DDVJA87MT8; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -555,7 +553,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.rr.interestCalculator; + PRODUCT_BUNDLE_IDENTIFIER = com.dsi.facebookAudienceNetworkExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; diff --git a/example/lib/main.dart b/example/lib/main.dart index da8ada7..7cf6c3a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,7 +6,6 @@ void main() => runApp(AdExampleApp()); class AdExampleApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( debugShowCheckedModeBanner: false, title: 'FB Audience Network Example', @@ -27,16 +26,12 @@ class AdExampleApp extends StatelessWidget { ), ); } - - } - class AdsPage extends StatefulWidget { - final String idfa; - const AdsPage({Key? key, this.idfa=''}) : super(key: key); + const AdsPage({Key? key, this.idfa = ''}) : super(key: key); @override AdsPageState createState() => AdsPageState(); @@ -58,22 +53,21 @@ class AdsPageState extends State { void initState() { super.initState(); - /// please add your own device testingId /// (testingId will print in console if you don't provide ) FacebookAudienceNetwork.init( testingId: "a77955ee-3304-4635-be65-81029b0f5201", + iOSAdvertiserTrackingEnabled: true, ); - _loadInterstitialAd(); _loadRewardedVideoAd(); } void _loadInterstitialAd() { FacebookInterstitialAd.loadInterstitialAd( - placementId: - "YOUR_PLACEMENT_ID", //"IMG_16_9_APP_INSTALL#2312433698835503_2650502525028617" YOUR_PLACEMENT_ID + // placementId: "YOUR_PLACEMENT_ID", + placementId: "IMG_16_9_APP_INSTALL#2312433698835503_2650502525028617", listener: (result, value) { print(">> FAN > Interstitial Ad: $result --> $value"); if (result == InterstitialAdResult.LOADED) @@ -189,9 +183,10 @@ class AdsPageState extends State { _showBannerAd() { setState(() { - _currentAd = FacebookBannerAd(placementId: "YOUR_PLACEMENT_ID", - // placementId: - // "IMG_16_9_APP_INSTALL#2312433698835503_2964944860251047", //testid + _currentAd = FacebookBannerAd( + // placementId: "YOUR_PLACEMENT_ID", + placementId: + "IMG_16_9_APP_INSTALL#2312433698835503_2964944860251047", //testid bannerSize: BannerSize.STANDARD, listener: (result, value) { print("Banner Ad: $result --> $value"); @@ -207,8 +202,9 @@ class AdsPageState extends State { } Widget _nativeBannerAd() { - return FacebookNativeAd(placementId: "YOUR_PLACEMENT_ID", - // placementId: "IMG_16_9_APP_INSTALL#2312433698835503_2964953543583512", + return FacebookNativeAd( + // placementId: "YOUR_PLACEMENT_ID", + placementId: "IMG_16_9_APP_INSTALL#2312433698835503_2964953543583512", adType: NativeAdType.NATIVE_BANNER_AD, bannerAdSize: NativeBannerAdSize.HEIGHT_100, width: double.infinity, @@ -232,7 +228,7 @@ class AdsPageState extends State { Widget _nativeAd() { return FacebookNativeAd( - // placementId: "IMG_16_9_APP_INSTALL#2312433698835503_2964952163583650", + placementId: "IMG_16_9_APP_INSTALL#2312433698835503_2964952163583650", adType: NativeAdType.NATIVE_AD_VERTICAL, width: double.infinity, height: 300, @@ -250,4 +246,3 @@ class AdsPageState extends State { ); } } - diff --git a/example/pubspec.lock b/example/pubspec.lock new file mode 100644 index 0000000..e1ccda8 --- /dev/null +++ b/example/pubspec.lock @@ -0,0 +1,161 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.6.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + facebook_audience_network: + dependency: "direct dev" + description: + path: ".." + relative: true + source: path + version: "1.0.0-nullsafety.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.10" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" +sdks: + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.10.0" diff --git a/ios/Classes/FANPluginFactory.swift b/ios/Classes/FANPluginFactory.swift index 01670e9..49843d5 100644 --- a/ios/Classes/FANPluginFactory.swift +++ b/ios/Classes/FANPluginFactory.swift @@ -12,9 +12,14 @@ class FANPluginFactory: NSObject { super.init() - channel.setMethodCallHandler { (call, result) in + channel.setMethodCallHandler { (_ call : FlutterMethodCall, result : @escaping FlutterResult) in switch call.method{ case "init": + if #available(iOS 14.0, *) { + let iOSAdvertiserTrackingEnabled = ((call.arguments as! Dictionary)["iOSAdvertiserTrackingEnabled"] as! NSString).boolValue + print("FANPluginFactory > iOSAdvertiserTrackingEnabled: " + String(iOSAdvertiserTrackingEnabled)) + FBAdSettings.setAdvertiserTrackingEnabled(iOSAdvertiserTrackingEnabled) + } print("FANPluginFactory > init") result(true) default: diff --git a/lib/facebook_audience_network.dart b/lib/facebook_audience_network.dart index 58122eb..01a8659 100644 --- a/lib/facebook_audience_network.dart +++ b/lib/facebook_audience_network.dart @@ -30,9 +30,11 @@ class FacebookAudienceNetwork { /// /// [testingId] can be obtained by running the app once without the testingId. /// Check the log to obtain the [testingId] for your device. - static Future init({String? testingId}) async { + static Future init( + {String? testingId, bool iOSAdvertiserTrackingEnabled = false}) async { Map initValues = { "testingId": testingId, + "iOSAdvertiserTrackingEnabled": iOSAdvertiserTrackingEnabled.toString(), }; try { diff --git a/pubspec.lock b/pubspec.lock index 41c945c..91d2fd2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -92,7 +92,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -127,7 +127,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 506fc71..28a618d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,7 +9,7 @@ homepage: https://github.com/dreamsoftin/facebook_audience_network environment: sdk: '>=2.12.0 <3.0.0' - flutter: ^1.10.0 + flutter: '>=1.10.0' dependencies: flutter: