質問編集履歴
6
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -248,6 +248,26 @@
|
|
248
248
|
|
249
249
|
rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
|
250
250
|
|
251
|
+
|
252
|
+
|
253
|
+
rewardedAd?.load(GADRequest()) { error in
|
254
|
+
|
255
|
+
if error != nil {
|
256
|
+
|
257
|
+
// Handle ad failed to load case.
|
258
|
+
|
259
|
+
print("読み込み失敗")
|
260
|
+
|
261
|
+
} else {
|
262
|
+
|
263
|
+
// Ad successfully loaded.
|
264
|
+
|
265
|
+
print("読み込み成功")
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
}
|
270
|
+
|
251
271
|
}
|
252
272
|
|
253
273
|
|
@@ -329,3 +349,39 @@
|
|
329
349
|
|
330
350
|
|
331
351
|
```
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
```
|
356
|
+
|
357
|
+
// デバッグエリアログ
|
358
|
+
|
359
|
+
読み込み成功
|
360
|
+
|
361
|
+
Rewarded ad presented.
|
362
|
+
|
363
|
+
Reward received with currency: coins, amount 10.
|
364
|
+
|
365
|
+
2021-02-28 14:59:02.513241+0900 iOS-Reward-Ad-Project[8303:164050] [View] First responder error: non-key window attempting reload - allowing due to manual keyboard (first responder window is <UIWindow: 0x7ffa14e12a80; frame = (0 0; 414 896); hidden = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x6000039291a0>; layer = <UIWindowLayer: 0x6000037f40e0>>, key window is <UIWindow: 0x7ffa14d09b80; frame = (0 0; 414 896); gestureRecognizers = <NSArray: 0x6000039f4d80>; layer = <UIWindowLayer: 0x60000379c080>>)
|
366
|
+
|
367
|
+
Rewarded ad dismissed.
|
368
|
+
|
369
|
+
2021-02-28 14:59:02.798589+0900 iOS-Reward-Ad-Project[8303:164050] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
|
370
|
+
|
371
|
+
2021-02-28 14:59:02.798776+0900 iOS-Reward-Ad-Project[8303:164050] [ProcessSuspension] 0x109dfe8c0 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 8311, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
|
372
|
+
|
373
|
+
2021-02-28 14:59:02.920755+0900 iOS-Reward-Ad-Project[8303:164050] [assertion] Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Suspended" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}>
|
374
|
+
|
375
|
+
2021-02-28 14:59:02.922318+0900 iOS-Reward-Ad-Project[8303:164050] [ProcessSuspension] 0x109dfe900 - ProcessAssertion: Failed to acquire RBS Suspended assertion 'WebProcess Suspended Assertion' for process with PID 8311, error: Error Domain=RBSAssertionErrorDomain Code=3 "Target is not running or required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Suspended" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Target is not running or required target entitlement is missing}
|
376
|
+
|
377
|
+
2021-02-28 14:59:02.999928+0900 iOS-Reward-Ad-Project[8303:164981] AudioObjectRemovePropertyListener: no object with given ID 0
|
378
|
+
|
379
|
+
2021-02-28 14:59:03.000632+0900 iOS-Reward-Ad-Project[8303:164981] AudioObjectRemovePropertyListener: no object with given ID 0
|
380
|
+
|
381
|
+
2021-02-28 14:59:03.001292+0900 iOS-Reward-Ad-Project[8303:164981] AudioObjectRemovePropertyListener: no object with given ID 0
|
382
|
+
|
383
|
+
2021-02-28 14:59:32.712346+0900 iOS-Reward-Ad-Project[8303:164050] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
```
|
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -221,3 +221,111 @@
|
|
221
221
|
```
|
222
222
|
|
223
223
|
![イメージ説明](84893f1012dda0c27455a69a463224be.png)
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
```修正後
|
230
|
+
|
231
|
+
import UIKit
|
232
|
+
|
233
|
+
import GoogleMobileAds
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
class RewardAdViewController: UIViewController, GADRewardedAdDelegate {
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
var rewardedAd: GADRewardedAd?
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
override func viewDidLoad() {
|
246
|
+
|
247
|
+
super.viewDidLoad()
|
248
|
+
|
249
|
+
rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
// MARK: - Navigation
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
@IBAction func stratRewardAd(_ sender: Any) {
|
260
|
+
|
261
|
+
if rewardedAd?.isReady == true {
|
262
|
+
|
263
|
+
rewardedAd?.present(fromRootViewController: self, delegate:self)
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
// MARK: - AdMob
|
272
|
+
|
273
|
+
/// Tells the delegate that the user earned a reward.
|
274
|
+
|
275
|
+
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarn reward: GADAdReward) {
|
276
|
+
|
277
|
+
print("Reward received with currency: (reward.type), amount (reward.amount).")
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
/// Tells the delegate that the rewarded ad was presented.
|
282
|
+
|
283
|
+
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
|
284
|
+
|
285
|
+
print("Rewarded ad presented.")
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
/// Tells the delegate that the rewarded ad was dismissed.
|
290
|
+
|
291
|
+
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
|
292
|
+
|
293
|
+
print("Rewarded ad dismissed.")
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
/// Tells the delegate that the rewarded ad failed to present.
|
298
|
+
|
299
|
+
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
|
300
|
+
|
301
|
+
print("Rewarded ad failed to present.")
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
func createAndLoadRewardedAd() {
|
306
|
+
|
307
|
+
rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
|
308
|
+
|
309
|
+
rewardedAd?.load(GADRequest()) { error in
|
310
|
+
|
311
|
+
if let error = error {
|
312
|
+
|
313
|
+
print("Loading failed: (error)")
|
314
|
+
|
315
|
+
} else {
|
316
|
+
|
317
|
+
print("Loading Succeeded")
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
// return rewardedAd
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
```
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,10 +118,14 @@
|
|
118
118
|
|
119
119
|
// Handle ad failed to load case.
|
120
120
|
|
121
|
+
print("読み込み失敗")
|
122
|
+
|
121
123
|
} else {
|
122
124
|
|
123
125
|
// Ad successfully loaded.
|
124
126
|
|
127
|
+
print("読み込み成功")
|
128
|
+
|
125
129
|
}
|
126
130
|
|
127
131
|
}
|
3
追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
AdMobのリワード広告を何度も呼び出したい
|
1
|
+
追記AdMobのリワード広告を何度も呼び出したい
|
test
CHANGED
@@ -73,3 +73,147 @@
|
|
73
73
|
|
74
74
|
|
75
75
|
詳しい方いましたらアドバイスお願いいたします。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
追記
|
80
|
+
|
81
|
+
ドキュメンそのままBuildするとエラーが4つ出ます。
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
//
|
88
|
+
|
89
|
+
// RewardAdViewController.swift
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
import UIKit
|
94
|
+
|
95
|
+
import GoogleMobileAds
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
class RewardAdViewController: UIViewController, GADRewardedAdDelegate {
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
var rewardedAd: GADRewardedAd?
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
override func viewDidLoad() {
|
108
|
+
|
109
|
+
super.viewDidLoad()
|
110
|
+
|
111
|
+
rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
rewardedAd?.load(GADRequest()) { error in
|
116
|
+
|
117
|
+
if let error = error {
|
118
|
+
|
119
|
+
// Handle ad failed to load case.
|
120
|
+
|
121
|
+
} else {
|
122
|
+
|
123
|
+
// Ad successfully loaded.
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
rewardedAd = createAndLoadRewardedAd()
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
// MARK: - Navigation
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
@IBAction func stratRewardAd(_ sender: Any) {
|
140
|
+
|
141
|
+
if rewardedAd?.isReady == true {
|
142
|
+
|
143
|
+
rewardedAd?.present(fromRootViewController: self, delegate:self)
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
// MARK: - AdMob
|
152
|
+
|
153
|
+
/// Tells the delegate that the user earned a reward.
|
154
|
+
|
155
|
+
func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarn reward: GADAdReward) {
|
156
|
+
|
157
|
+
print("Reward received with currency: (reward.type), amount (reward.amount).")
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
/// Tells the delegate that the rewarded ad was presented.
|
162
|
+
|
163
|
+
func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
|
164
|
+
|
165
|
+
print("Rewarded ad presented.")
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
/// Tells the delegate that the rewarded ad was dismissed.
|
170
|
+
|
171
|
+
func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
|
172
|
+
|
173
|
+
print("Rewarded ad dismissed.")
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
rewardedAd = createAndLoadRewardedAd()
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
/// Tells the delegate that the rewarded ad failed to present.
|
184
|
+
|
185
|
+
func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
|
186
|
+
|
187
|
+
print("Rewarded ad failed to present.")
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
func createAndLoadRewardedAd() {
|
192
|
+
|
193
|
+
rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
|
194
|
+
|
195
|
+
rewardedAd?.load(GADRequest()) { error in
|
196
|
+
|
197
|
+
if let error = error {
|
198
|
+
|
199
|
+
print("Loading failed: (error)")
|
200
|
+
|
201
|
+
} else {
|
202
|
+
|
203
|
+
print("Loading Succeeded")
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
return rewardedAd
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
![イメージ説明](84893f1012dda0c27455a69a463224be.png)
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,7 +42,9 @@
|
|
42
42
|
|
43
43
|
```
|
44
44
|
|
45
|
-
(も書いてみたのですがそもそも `警告`が出ているので微妙です。)
|
45
|
+
~~(も書いてみたのですがそもそも `警告`が出ているので微妙です。)~~
|
46
|
+
|
47
|
+
`GADRewardBasedVideoAd`は非推奨のようなので `Fix`で修正しています。
|
46
48
|
|
47
49
|
|
48
50
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,9 +54,19 @@
|
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
広告が表示されないのはテスト広告だからでしょうか
|
57
|
+
広告が表示されないのはテスト広告だからでしょうか。
|
58
58
|
|
59
|
-
それともドキュメント通りの実装だと1種類の広告しか出ないのでしょうか
|
59
|
+
それともドキュメント通りの実装だと1種類の広告しか出ないのでしょうか。
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
## 知りたいこと
|
66
|
+
|
67
|
+
・リワード広告を呼び出すたびに違う広告を表示して試聴時間が一定時間経過するとポイントが付与される実装が知りたいです。
|
68
|
+
|
69
|
+
```
|
60
70
|
|
61
71
|
|
62
72
|
|