teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

コードの削除

2021/02/02 12:19

投稿

rea_sna
rea_sna

スコア32

title CHANGED
File without changes
body CHANGED
@@ -28,134 +28,7 @@
28
28
 
29
29
  ・Firebaseにアプリをリンクさせたのも8時間ほど前。
30
30
 
31
- ###追記 広告表示部分のコード (2021/02/01)
32
- ```Swift
33
- ---------------------
34
- Appdelegate.swift
35
- ---------------------
36
31
 
37
- import UIKit
38
- import SwiftyStoreKit
39
- import Firebase
40
-
41
- @main
42
- class AppDelegate: UIResponder, UIApplicationDelegate {
43
-
44
-
45
-
46
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
47
- // Override point for customization after application launch.
48
-
49
- //MARK:- SwiftyStoreKit Transaction
50
- SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
51
- for purchase in purchases {
52
- switch purchase.transaction.transactionState {
53
- case .purchased, .restored:
54
- if purchase.needsFinishTransaction {
55
- // Deliver content from server, then:
56
- SwiftyStoreKit.finishTransaction(purchase.transaction)
57
- }
58
- // Unlock content
59
- case .failed, .purchasing, .deferred:
60
- break // do nothing
61
- }
62
- }
63
- }
64
-
65
- FirebaseApp.configure()
66
- GADMobileAds.sharedInstance().start(completionHandler: nil)
67
-
68
-
69
- return true
70
- }
71
-
72
- <以下のコードに変更はありません>
73
- ```
74
-
75
- ```Swift
76
- ---------------------
77
- ViewController1.swift
78
- ---------------------
79
-
80
- import UIKit
81
- import MaterialComponents
82
- import PKHUD
83
- import RealmSwift
84
- import Realm
85
- import StoreKit
86
- import GoogleMobileAds
87
- import FirebaseAnalytics
88
-
89
- class ViewController1: UIViewController, SKStoreProductViewControllerDelegate, UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate, GADBannerViewDelegate {
90
-
91
- <中略>
92
-
93
- var bannerView: GADBannerView!
94
-
95
- override func viewDidLoad() {
96
- super.viewDidLoad()
97
-
98
- storeProductVC.delegate = self
99
-
100
- tableView.dataSource = self
101
- tableView.delegate = self
102
-
103
- // MARK: - バーナー広告の実装
104
- bannerView.delegate = self
105
-
106
- bannerView = GADBannerView(adSize: kGADAdSizeBanner)
107
- addBannerViewToView(bannerView)
108
-
109
- // ユニットID
110
- bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716" //テスト用
111
- bannerView.rootViewController = self
112
-
113
- bannerView.load(GADRequest())
114
-
115
- }
116
-
117
- // MARK: - GAD Event
118
-
119
- /// Tells the delegate an ad request loaded an ad.
120
- func adViewDidReceiveAd(_ bannerView: GADBannerView) {
121
- print("adViewDidReceiveAd")
122
-
123
- // バナーアニメーション
124
- bannerView.alpha = 0
125
- UIView.animate(withDuration: 1, animations: {
126
- bannerView.alpha = 1
127
- })
128
- }
129
-
130
- /// Tells the delegate an ad request failed.
131
- func adView(_ bannerView: GADBannerView,
132
- didFailToReceiveAdWithError error: GADRequestError) {
133
- print("adView:didFailToReceiveAdWithError: (error.localizedDescription)")
134
- }
135
-
136
- /// Tells the delegate that a full-screen view will be presented in response
137
- /// to the user clicking on an ad.
138
- func adViewWillPresentScreen(_ bannerView: GADBannerView) {
139
- print("adViewWillPresentScreen")
140
- }
141
-
142
- /// Tells the delegate that the full-screen view will be dismissed.
143
- func adViewWillDismissScreen(_ bannerView: GADBannerView) {
144
- print("adViewWillDismissScreen")
145
- }
146
-
147
- /// Tells the delegate that the full-screen view has been dismissed.
148
- func adViewDidDismissScreen(_ bannerView: GADBannerView) {
149
- print("adViewDidDismissScreen")
150
- }
151
-
152
- /// Tells the delegate that a user click will open another app (such as
153
- /// the App Store), backgrounding the current app.
154
- func adViewWillLeaveApplication(_ bannerView: GADBannerView) {
155
- print("adViewWillLeaveApplication")
156
- }
157
- ```
158
-
159
32
  ### 環境
160
33
  Xcode 12.4
161
34
  Google Mobile Ads SDK 7.69.0

2

コードの追記

2021/02/02 12:19

投稿

rea_sna
rea_sna

スコア32

title CHANGED
File without changes
body CHANGED
@@ -28,6 +28,134 @@
28
28
 
29
29
  ・Firebaseにアプリをリンクさせたのも8時間ほど前。
30
30
 
31
+ ###追記 広告表示部分のコード (2021/02/01)
32
+ ```Swift
33
+ ---------------------
34
+ Appdelegate.swift
35
+ ---------------------
36
+
37
+ import UIKit
38
+ import SwiftyStoreKit
39
+ import Firebase
40
+
41
+ @main
42
+ class AppDelegate: UIResponder, UIApplicationDelegate {
43
+
44
+
45
+
46
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
47
+ // Override point for customization after application launch.
48
+
49
+ //MARK:- SwiftyStoreKit Transaction
50
+ SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
51
+ for purchase in purchases {
52
+ switch purchase.transaction.transactionState {
53
+ case .purchased, .restored:
54
+ if purchase.needsFinishTransaction {
55
+ // Deliver content from server, then:
56
+ SwiftyStoreKit.finishTransaction(purchase.transaction)
57
+ }
58
+ // Unlock content
59
+ case .failed, .purchasing, .deferred:
60
+ break // do nothing
61
+ }
62
+ }
63
+ }
64
+
65
+ FirebaseApp.configure()
66
+ GADMobileAds.sharedInstance().start(completionHandler: nil)
67
+
68
+
69
+ return true
70
+ }
71
+
72
+ <以下のコードに変更はありません>
73
+ ```
74
+
75
+ ```Swift
76
+ ---------------------
77
+ ViewController1.swift
78
+ ---------------------
79
+
80
+ import UIKit
81
+ import MaterialComponents
82
+ import PKHUD
83
+ import RealmSwift
84
+ import Realm
85
+ import StoreKit
86
+ import GoogleMobileAds
87
+ import FirebaseAnalytics
88
+
89
+ class ViewController1: UIViewController, SKStoreProductViewControllerDelegate, UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate, GADBannerViewDelegate {
90
+
91
+ <中略>
92
+
93
+ var bannerView: GADBannerView!
94
+
95
+ override func viewDidLoad() {
96
+ super.viewDidLoad()
97
+
98
+ storeProductVC.delegate = self
99
+
100
+ tableView.dataSource = self
101
+ tableView.delegate = self
102
+
103
+ // MARK: - バーナー広告の実装
104
+ bannerView.delegate = self
105
+
106
+ bannerView = GADBannerView(adSize: kGADAdSizeBanner)
107
+ addBannerViewToView(bannerView)
108
+
109
+ // ユニットID
110
+ bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716" //テスト用
111
+ bannerView.rootViewController = self
112
+
113
+ bannerView.load(GADRequest())
114
+
115
+ }
116
+
117
+ // MARK: - GAD Event
118
+
119
+ /// Tells the delegate an ad request loaded an ad.
120
+ func adViewDidReceiveAd(_ bannerView: GADBannerView) {
121
+ print("adViewDidReceiveAd")
122
+
123
+ // バナーアニメーション
124
+ bannerView.alpha = 0
125
+ UIView.animate(withDuration: 1, animations: {
126
+ bannerView.alpha = 1
127
+ })
128
+ }
129
+
130
+ /// Tells the delegate an ad request failed.
131
+ func adView(_ bannerView: GADBannerView,
132
+ didFailToReceiveAdWithError error: GADRequestError) {
133
+ print("adView:didFailToReceiveAdWithError: (error.localizedDescription)")
134
+ }
135
+
136
+ /// Tells the delegate that a full-screen view will be presented in response
137
+ /// to the user clicking on an ad.
138
+ func adViewWillPresentScreen(_ bannerView: GADBannerView) {
139
+ print("adViewWillPresentScreen")
140
+ }
141
+
142
+ /// Tells the delegate that the full-screen view will be dismissed.
143
+ func adViewWillDismissScreen(_ bannerView: GADBannerView) {
144
+ print("adViewWillDismissScreen")
145
+ }
146
+
147
+ /// Tells the delegate that the full-screen view has been dismissed.
148
+ func adViewDidDismissScreen(_ bannerView: GADBannerView) {
149
+ print("adViewDidDismissScreen")
150
+ }
151
+
152
+ /// Tells the delegate that a user click will open another app (such as
153
+ /// the App Store), backgrounding the current app.
154
+ func adViewWillLeaveApplication(_ bannerView: GADBannerView) {
155
+ print("adViewWillLeaveApplication")
156
+ }
157
+ ```
158
+
31
159
  ### 環境
32
160
  Xcode 12.4
33
161
  Google Mobile Ads SDK 7.69.0
@@ -35,4 +163,6 @@
35
163
 
36
164
 
37
165
  かなり時間をかけて原因を探したり、podのインストールからやり直してみたりしましたが、依然状況は変わりません。
38
- 細かなことでも構いませんので、ご教授いただければと思います。よろしくお願い致します。
166
+ 細かなことでも構いませんので、ご教授いただければと思います。よろしくお願い致します。
167
+
168
+ Info.plistの再ダウンロード等も行いました。

1

誤字の修正

2021/02/01 12:23

投稿

rea_sna
rea_sna

スコア32

title CHANGED
File without changes
body CHANGED
@@ -5,13 +5,13 @@
5
5
  Thread 2: "The Google Mobile Ads SDK was initialized without AppMeasurement. Google AdMob publishers, follow instructions here: https://googlemobileadssdk.page.link/admob-ios-update-plist to include the AppMeasurement framework and set the -ObjC linker flag. Google Ad Manager publishers, follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist"
6
6
 
7
7
  ### 現状
8
- Admob管理画面でのアプリの追加、ユニットの作成も行いました。実装しているのは、バナー広告です。
8
+ Admob管理画面でのアプリの追加、ユニットの作成も行いました。実装しているのは、バナー広告です。
9
9
 
10
10
  AppStoreでのリリースは行っていません。
11
11
 
12
12
  Admobクイックスタート([https://firebase.google.com/docs/admob/ios/quick-start?hl=ja](https://firebase.google.com/docs/admob/ios/quick-start?hl=ja))に記載されている手順は全て行いました。
13
13
 
14
- ナー広告のドキュメント([https://developers.google.com/admob/ios/banner?hl=ja](https://developers.google.com/admob/ios/banner?hl=ja))に記載されていることも行いました。
14
+ バナー広告のドキュメント([https://developers.google.com/admob/ios/banner?hl=ja](https://developers.google.com/admob/ios/banner?hl=ja))に記載されていることも行いました。
15
15
  (現在はバナー広告向けのテスト専用広告ユニット IDを使用中ですが、作成したユニットIDでもできませんでした)
16
16
 
17
17
  `Info.plist`への`GADApplicationIdentifier`キーの追加、`SKAdNetworkItems`キーの追加も行いました。