Skip to content

Commit

Permalink
Merge pull request #53 from RikitoNoto/construct_ios_ads
Browse files Browse the repository at this point in the history
Construct ios ads
  • Loading branch information
RikitoNoto authored Aug 27, 2023
2 parents 72739be + ca33a1a commit a4a576d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion android/app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
admobAppIdDebug=ca-app-pub-3940256099942544~3347511713
admobAppIdRelease=ca-app-pub-9865959999329879/8255171291
admobAppIdRelease=ca-app-pub-9865959999329879~1717435686
26 changes: 25 additions & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -143,6 +143,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
908E0665476C5F917460FA09 /* [CP] Embed Pods Frameworks */,
F46532AEF45C1E6B8BA71645 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -205,10 +206,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -258,6 +261,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -270,6 +274,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
F46532AEF45C1E6B8BA71645 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -368,6 +389,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ADMOD_ID = "";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
Expand Down Expand Up @@ -501,6 +523,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ADMOD_ID = "ca-app-pub-3940256099942544~3347511713";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
Expand All @@ -526,6 +549,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ADMOD_ID = "ca-app-pub-9865959999329879~8483283885";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
Expand Down
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>GADApplicationIdentifier</key>
<string>${ADMOD_ID}</string>
</dict>
</plist>
12 changes: 7 additions & 5 deletions lib/ads/ad_helper.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:platform/platform.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

class AdHelper {
AdHelper({
Expand All @@ -22,15 +20,19 @@ class AdHelper {
} else {
return 'ca-app-pub-9865959999329879/8255171291';
}
// } else if (Platform.isIOS) {
// return '<YOUR_IOS_BANNER_AD_UNIT_ID>';
} else if (platform.isIOS) {
if (kDebugMode) {
return 'ca-app-pub-3940256099942544/2934735716';
} else {
return 'ca-app-pub-9865959999329879/3977062661';
}
} else {
return '';
}
}

void initBannerAd({void Function(Ad)? onAdLoaded}) {
if (platform.isAndroid) {
if (platform.isAndroid || platform.isIOS) {
initGoogleMobileAds();
BannerAd(
adUnitId: bannerAdUnitId,
Expand Down

0 comments on commit a4a576d

Please sign in to comment.