質問編集履歴

3

コードの削除

2021/02/02 12:19

投稿

rea_sna
rea_sna

スコア32

test CHANGED
File without changes
test CHANGED
@@ -58,260 +58,6 @@
58
58
 
59
59
 
60
60
 
61
- ###追記 広告表示部分のコード (2021/02/01)
62
-
63
- ```Swift
64
-
65
- ---------------------
66
-
67
- Appdelegate.swift
68
-
69
- ---------------------
70
-
71
-
72
-
73
- import UIKit
74
-
75
- import SwiftyStoreKit
76
-
77
- import Firebase
78
-
79
-
80
-
81
- @main
82
-
83
- class AppDelegate: UIResponder, UIApplicationDelegate {
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
92
-
93
- // Override point for customization after application launch.
94
-
95
-
96
-
97
- //MARK:- SwiftyStoreKit Transaction
98
-
99
- SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
100
-
101
- for purchase in purchases {
102
-
103
- switch purchase.transaction.transactionState {
104
-
105
- case .purchased, .restored:
106
-
107
- if purchase.needsFinishTransaction {
108
-
109
- // Deliver content from server, then:
110
-
111
- SwiftyStoreKit.finishTransaction(purchase.transaction)
112
-
113
- }
114
-
115
- // Unlock content
116
-
117
- case .failed, .purchasing, .deferred:
118
-
119
- break // do nothing
120
-
121
- }
122
-
123
- }
124
-
125
- }
126
-
127
-
128
-
129
- FirebaseApp.configure()
130
-
131
- GADMobileAds.sharedInstance().start(completionHandler: nil)
132
-
133
-
134
-
135
-
136
-
137
- return true
138
-
139
- }
140
-
141
-
142
-
143
- <以下のコードに変更はありません>
144
-
145
- ```
146
-
147
-
148
-
149
- ```Swift
150
-
151
- ---------------------
152
-
153
- ViewController1.swift
154
-
155
- ---------------------
156
-
157
-
158
-
159
- import UIKit
160
-
161
- import MaterialComponents
162
-
163
- import PKHUD
164
-
165
- import RealmSwift
166
-
167
- import Realm
168
-
169
- import StoreKit
170
-
171
- import GoogleMobileAds
172
-
173
- import FirebaseAnalytics
174
-
175
-
176
-
177
- class ViewController1: UIViewController, SKStoreProductViewControllerDelegate, UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate, GADBannerViewDelegate {
178
-
179
-
180
-
181
- <中略>
182
-
183
-
184
-
185
- var bannerView: GADBannerView!
186
-
187
-
188
-
189
- override func viewDidLoad() {
190
-
191
- super.viewDidLoad()
192
-
193
-
194
-
195
- storeProductVC.delegate = self
196
-
197
-
198
-
199
- tableView.dataSource = self
200
-
201
- tableView.delegate = self
202
-
203
-
204
-
205
- // MARK: - バーナー広告の実装
206
-
207
- bannerView.delegate = self
208
-
209
-
210
-
211
- bannerView = GADBannerView(adSize: kGADAdSizeBanner)
212
-
213
- addBannerViewToView(bannerView)
214
-
215
-
216
-
217
- // ユニットID
218
-
219
- bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716" //テスト用
220
-
221
- bannerView.rootViewController = self
222
-
223
-
224
-
225
- bannerView.load(GADRequest())
226
-
227
-
228
-
229
- }
230
-
231
-
232
-
233
- // MARK: - GAD Event
234
-
235
-
236
-
237
- /// Tells the delegate an ad request loaded an ad.
238
-
239
- func adViewDidReceiveAd(_ bannerView: GADBannerView) {
240
-
241
- print("adViewDidReceiveAd")
242
-
243
-
244
-
245
- // バナーアニメーション
246
-
247
- bannerView.alpha = 0
248
-
249
- UIView.animate(withDuration: 1, animations: {
250
-
251
- bannerView.alpha = 1
252
-
253
- })
254
-
255
- }
256
-
257
-
258
-
259
- /// Tells the delegate an ad request failed.
260
-
261
- func adView(_ bannerView: GADBannerView,
262
-
263
- didFailToReceiveAdWithError error: GADRequestError) {
264
-
265
- print("adView:didFailToReceiveAdWithError: (error.localizedDescription)")
266
-
267
- }
268
-
269
-
270
-
271
- /// Tells the delegate that a full-screen view will be presented in response
272
-
273
- /// to the user clicking on an ad.
274
-
275
- func adViewWillPresentScreen(_ bannerView: GADBannerView) {
276
-
277
- print("adViewWillPresentScreen")
278
-
279
- }
280
-
281
-
282
-
283
- /// Tells the delegate that the full-screen view will be dismissed.
284
-
285
- func adViewWillDismissScreen(_ bannerView: GADBannerView) {
286
-
287
- print("adViewWillDismissScreen")
288
-
289
- }
290
-
291
-
292
-
293
- /// Tells the delegate that the full-screen view has been dismissed.
294
-
295
- func adViewDidDismissScreen(_ bannerView: GADBannerView) {
296
-
297
- print("adViewDidDismissScreen")
298
-
299
- }
300
-
301
-
302
-
303
- /// Tells the delegate that a user click will open another app (such as
304
-
305
- /// the App Store), backgrounding the current app.
306
-
307
- func adViewWillLeaveApplication(_ bannerView: GADBannerView) {
308
-
309
- print("adViewWillLeaveApplication")
310
-
311
- }
312
-
313
- ```
314
-
315
61
 
316
62
 
317
63
  ### 環境

2

コードの追記

2021/02/02 12:19

投稿

rea_sna
rea_sna

スコア32

test CHANGED
File without changes
test CHANGED
@@ -58,6 +58,262 @@
58
58
 
59
59
 
60
60
 
61
+ ###追記 広告表示部分のコード (2021/02/01)
62
+
63
+ ```Swift
64
+
65
+ ---------------------
66
+
67
+ Appdelegate.swift
68
+
69
+ ---------------------
70
+
71
+
72
+
73
+ import UIKit
74
+
75
+ import SwiftyStoreKit
76
+
77
+ import Firebase
78
+
79
+
80
+
81
+ @main
82
+
83
+ class AppDelegate: UIResponder, UIApplicationDelegate {
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
92
+
93
+ // Override point for customization after application launch.
94
+
95
+
96
+
97
+ //MARK:- SwiftyStoreKit Transaction
98
+
99
+ SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
100
+
101
+ for purchase in purchases {
102
+
103
+ switch purchase.transaction.transactionState {
104
+
105
+ case .purchased, .restored:
106
+
107
+ if purchase.needsFinishTransaction {
108
+
109
+ // Deliver content from server, then:
110
+
111
+ SwiftyStoreKit.finishTransaction(purchase.transaction)
112
+
113
+ }
114
+
115
+ // Unlock content
116
+
117
+ case .failed, .purchasing, .deferred:
118
+
119
+ break // do nothing
120
+
121
+ }
122
+
123
+ }
124
+
125
+ }
126
+
127
+
128
+
129
+ FirebaseApp.configure()
130
+
131
+ GADMobileAds.sharedInstance().start(completionHandler: nil)
132
+
133
+
134
+
135
+
136
+
137
+ return true
138
+
139
+ }
140
+
141
+
142
+
143
+ <以下のコードに変更はありません>
144
+
145
+ ```
146
+
147
+
148
+
149
+ ```Swift
150
+
151
+ ---------------------
152
+
153
+ ViewController1.swift
154
+
155
+ ---------------------
156
+
157
+
158
+
159
+ import UIKit
160
+
161
+ import MaterialComponents
162
+
163
+ import PKHUD
164
+
165
+ import RealmSwift
166
+
167
+ import Realm
168
+
169
+ import StoreKit
170
+
171
+ import GoogleMobileAds
172
+
173
+ import FirebaseAnalytics
174
+
175
+
176
+
177
+ class ViewController1: UIViewController, SKStoreProductViewControllerDelegate, UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate, GADBannerViewDelegate {
178
+
179
+
180
+
181
+ <中略>
182
+
183
+
184
+
185
+ var bannerView: GADBannerView!
186
+
187
+
188
+
189
+ override func viewDidLoad() {
190
+
191
+ super.viewDidLoad()
192
+
193
+
194
+
195
+ storeProductVC.delegate = self
196
+
197
+
198
+
199
+ tableView.dataSource = self
200
+
201
+ tableView.delegate = self
202
+
203
+
204
+
205
+ // MARK: - バーナー広告の実装
206
+
207
+ bannerView.delegate = self
208
+
209
+
210
+
211
+ bannerView = GADBannerView(adSize: kGADAdSizeBanner)
212
+
213
+ addBannerViewToView(bannerView)
214
+
215
+
216
+
217
+ // ユニットID
218
+
219
+ bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716" //テスト用
220
+
221
+ bannerView.rootViewController = self
222
+
223
+
224
+
225
+ bannerView.load(GADRequest())
226
+
227
+
228
+
229
+ }
230
+
231
+
232
+
233
+ // MARK: - GAD Event
234
+
235
+
236
+
237
+ /// Tells the delegate an ad request loaded an ad.
238
+
239
+ func adViewDidReceiveAd(_ bannerView: GADBannerView) {
240
+
241
+ print("adViewDidReceiveAd")
242
+
243
+
244
+
245
+ // バナーアニメーション
246
+
247
+ bannerView.alpha = 0
248
+
249
+ UIView.animate(withDuration: 1, animations: {
250
+
251
+ bannerView.alpha = 1
252
+
253
+ })
254
+
255
+ }
256
+
257
+
258
+
259
+ /// Tells the delegate an ad request failed.
260
+
261
+ func adView(_ bannerView: GADBannerView,
262
+
263
+ didFailToReceiveAdWithError error: GADRequestError) {
264
+
265
+ print("adView:didFailToReceiveAdWithError: (error.localizedDescription)")
266
+
267
+ }
268
+
269
+
270
+
271
+ /// Tells the delegate that a full-screen view will be presented in response
272
+
273
+ /// to the user clicking on an ad.
274
+
275
+ func adViewWillPresentScreen(_ bannerView: GADBannerView) {
276
+
277
+ print("adViewWillPresentScreen")
278
+
279
+ }
280
+
281
+
282
+
283
+ /// Tells the delegate that the full-screen view will be dismissed.
284
+
285
+ func adViewWillDismissScreen(_ bannerView: GADBannerView) {
286
+
287
+ print("adViewWillDismissScreen")
288
+
289
+ }
290
+
291
+
292
+
293
+ /// Tells the delegate that the full-screen view has been dismissed.
294
+
295
+ func adViewDidDismissScreen(_ bannerView: GADBannerView) {
296
+
297
+ print("adViewDidDismissScreen")
298
+
299
+ }
300
+
301
+
302
+
303
+ /// Tells the delegate that a user click will open another app (such as
304
+
305
+ /// the App Store), backgrounding the current app.
306
+
307
+ func adViewWillLeaveApplication(_ bannerView: GADBannerView) {
308
+
309
+ print("adViewWillLeaveApplication")
310
+
311
+ }
312
+
313
+ ```
314
+
315
+
316
+
61
317
  ### 環境
62
318
 
63
319
  Xcode 12.4
@@ -73,3 +329,7 @@
73
329
  かなり時間をかけて原因を探したり、podのインストールからやり直してみたりしましたが、依然状況は変わりません。
74
330
 
75
331
  細かなことでも構いませんので、ご教授いただければと思います。よろしくお願い致します。
332
+
333
+
334
+
335
+ Info.plistの再ダウンロード等も行いました。

1

誤字の修正

2021/02/01 12:23

投稿

rea_sna
rea_sna

スコア32

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ### 現状
14
14
 
15
- Admob管理画面でのアプリの追加、ユニットの作成も行いました。実装しているのは、バナー広告です。
15
+ Admob管理画面でのアプリの追加、ユニットの作成も行いました。実装しているのは、バナー広告です。
16
16
 
17
17
 
18
18
 
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- ナー広告のドキュメント([https://developers.google.com/admob/ios/banner?hl=ja](https://developers.google.com/admob/ios/banner?hl=ja))に記載されていることも行いました。
27
+ バナー広告のドキュメント([https://developers.google.com/admob/ios/banner?hl=ja](https://developers.google.com/admob/ios/banner?hl=ja))に記載されていることも行いました。
28
28
 
29
29
  (現在はバナー広告向けのテスト専用広告ユニット IDを使用中ですが、作成したユニットIDでもできませんでした)
30
30