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

質問編集履歴

6

追記

2021/02/28 06:03

投稿

sunglass
sunglass

スコア303

title CHANGED
File without changes
body CHANGED
@@ -123,6 +123,16 @@
123
123
  override func viewDidLoad() {
124
124
  super.viewDidLoad()
125
125
  rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
126
+
127
+ rewardedAd?.load(GADRequest()) { error in
128
+ if error != nil {
129
+ // Handle ad failed to load case.
130
+ print("読み込み失敗")
131
+ } else {
132
+ // Ad successfully loaded.
133
+ print("読み込み成功")
134
+ }
135
+ }
126
136
  }
127
137
 
128
138
  // MARK: - Navigation
@@ -163,4 +173,22 @@
163
173
  }
164
174
  }
165
175
 
176
+ ```
177
+
178
+ ```
179
+ // デバッグエリアログ
180
+ 読み込み成功
181
+ Rewarded ad presented.
182
+ Reward received with currency: coins, amount 10.
183
+ 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>>)
184
+ Rewarded ad dismissed.
185
+ 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}>
186
+ 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}
187
+ 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}>
188
+ 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}
189
+ 2021-02-28 14:59:02.999928+0900 iOS-Reward-Ad-Project[8303:164981] AudioObjectRemovePropertyListener: no object with given ID 0
190
+ 2021-02-28 14:59:03.000632+0900 iOS-Reward-Ad-Project[8303:164981] AudioObjectRemovePropertyListener: no object with given ID 0
191
+ 2021-02-28 14:59:03.001292+0900 iOS-Reward-Ad-Project[8303:164981] AudioObjectRemovePropertyListener: no object with given ID 0
192
+ 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
193
+
166
194
  ```

5

修正

2021/02/28 06:03

投稿

sunglass
sunglass

スコア303

title CHANGED
File without changes
body CHANGED
@@ -109,4 +109,58 @@
109
109
  }
110
110
 
111
111
  ```
112
- ![イメージ説明](84893f1012dda0c27455a69a463224be.png)
112
+ ![イメージ説明](84893f1012dda0c27455a69a463224be.png)
113
+
114
+
115
+ ```修正後
116
+ import UIKit
117
+ import GoogleMobileAds
118
+
119
+ class RewardAdViewController: UIViewController, GADRewardedAdDelegate {
120
+
121
+ var rewardedAd: GADRewardedAd?
122
+
123
+ override func viewDidLoad() {
124
+ super.viewDidLoad()
125
+ rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
126
+ }
127
+
128
+ // MARK: - Navigation
129
+
130
+ @IBAction func stratRewardAd(_ sender: Any) {
131
+ if rewardedAd?.isReady == true {
132
+ rewardedAd?.present(fromRootViewController: self, delegate:self)
133
+ }
134
+ }
135
+
136
+ // MARK: - AdMob
137
+ /// Tells the delegate that the user earned a reward.
138
+ func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarn reward: GADAdReward) {
139
+ print("Reward received with currency: (reward.type), amount (reward.amount).")
140
+ }
141
+ /// Tells the delegate that the rewarded ad was presented.
142
+ func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
143
+ print("Rewarded ad presented.")
144
+ }
145
+ /// Tells the delegate that the rewarded ad was dismissed.
146
+ func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
147
+ print("Rewarded ad dismissed.")
148
+ }
149
+ /// Tells the delegate that the rewarded ad failed to present.
150
+ func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
151
+ print("Rewarded ad failed to present.")
152
+ }
153
+ func createAndLoadRewardedAd() {
154
+ rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
155
+ rewardedAd?.load(GADRequest()) { error in
156
+ if let error = error {
157
+ print("Loading failed: (error)")
158
+ } else {
159
+ print("Loading Succeeded")
160
+ }
161
+ }
162
+ // return rewardedAd
163
+ }
164
+ }
165
+
166
+ ```

4

修正

2021/02/28 05:49

投稿

sunglass
sunglass

スコア303

title CHANGED
File without changes
body CHANGED
@@ -58,8 +58,10 @@
58
58
  rewardedAd?.load(GADRequest()) { error in
59
59
  if let error = error {
60
60
  // Handle ad failed to load case.
61
+ print("読み込み失敗")
61
62
  } else {
62
63
  // Ad successfully loaded.
64
+ print("読み込み成功")
63
65
  }
64
66
  }
65
67
  rewardedAd = createAndLoadRewardedAd()

3

追記

2021/02/27 16:25

投稿

sunglass
sunglass

スコア303

title CHANGED
@@ -1,1 +1,1 @@
1
- AdMobのリワード広告を何度も呼び出したい
1
+ 追記AdMobのリワード広告を何度も呼び出したい
body CHANGED
@@ -35,4 +35,76 @@
35
35
  ・リワード広告を呼び出すたびに違う広告を表示して試聴時間が一定時間経過するとポイントが付与される実装が知りたいです。
36
36
  ```
37
37
 
38
- 詳しい方いましたらアドバイスお願いいたします。
38
+ 詳しい方いましたらアドバイスお願いいたします。
39
+
40
+ 追記
41
+ ドキュメンそのままBuildするとエラーが4つ出ます。
42
+
43
+ ```
44
+ //
45
+ // RewardAdViewController.swift
46
+
47
+ import UIKit
48
+ import GoogleMobileAds
49
+
50
+ class RewardAdViewController: UIViewController, GADRewardedAdDelegate {
51
+
52
+ var rewardedAd: GADRewardedAd?
53
+
54
+ override func viewDidLoad() {
55
+ super.viewDidLoad()
56
+ rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
57
+
58
+ rewardedAd?.load(GADRequest()) { error in
59
+ if let error = error {
60
+ // Handle ad failed to load case.
61
+ } else {
62
+ // Ad successfully loaded.
63
+ }
64
+ }
65
+ rewardedAd = createAndLoadRewardedAd()
66
+ }
67
+
68
+ // MARK: - Navigation
69
+
70
+ @IBAction func stratRewardAd(_ sender: Any) {
71
+ if rewardedAd?.isReady == true {
72
+ rewardedAd?.present(fromRootViewController: self, delegate:self)
73
+ }
74
+ }
75
+
76
+ // MARK: - AdMob
77
+ /// Tells the delegate that the user earned a reward.
78
+ func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarn reward: GADAdReward) {
79
+ print("Reward received with currency: (reward.type), amount (reward.amount).")
80
+ }
81
+ /// Tells the delegate that the rewarded ad was presented.
82
+ func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) {
83
+ print("Rewarded ad presented.")
84
+ }
85
+ /// Tells the delegate that the rewarded ad was dismissed.
86
+ func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) {
87
+ print("Rewarded ad dismissed.")
88
+
89
+ rewardedAd = createAndLoadRewardedAd()
90
+
91
+ }
92
+ /// Tells the delegate that the rewarded ad failed to present.
93
+ func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) {
94
+ print("Rewarded ad failed to present.")
95
+ }
96
+ func createAndLoadRewardedAd() {
97
+ rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313")
98
+ rewardedAd?.load(GADRequest()) { error in
99
+ if let error = error {
100
+ print("Loading failed: (error)")
101
+ } else {
102
+ print("Loading Succeeded")
103
+ }
104
+ }
105
+ return rewardedAd
106
+ }
107
+ }
108
+
109
+ ```
110
+ ![イメージ説明](84893f1012dda0c27455a69a463224be.png)

2

修正

2021/02/27 16:21

投稿

sunglass
sunglass

スコア303

title CHANGED
File without changes
body CHANGED
@@ -20,7 +20,8 @@
20
20
  print("Reward based video ad is closed.")
21
21
  }
22
22
  ```
23
- (も書いてみたのですがそもそも `警告`が出ているので微妙です。)
23
+ ~~(も書いてみたのですがそもそも `警告`が出ているので微妙です。)~~
24
+ `GADRewardBasedVideoAd`は非推奨のようなので `Fix`で修正しています。
24
25
 
25
26
  ボタンを押して何回か(例:3回を上限とする)リワード広告を表示して
26
27
  `ポイントを付与`したいです。

1

追記

2021/02/27 04:46

投稿

sunglass
sunglass

スコア303

title CHANGED
File without changes
body CHANGED
@@ -26,7 +26,12 @@
26
26
  `ポイントを付与`したいです。
27
27
  言語は `Swift`です。
28
28
 
29
- 広告が表示されないのはテスト広告だからでしょうか
29
+ 広告が表示されないのはテスト広告だからでしょうか
30
- それともドキュメント通りの実装だと1種類の広告しか出ないのでしょうか
30
+ それともドキュメント通りの実装だと1種類の広告しか出ないのでしょうか
31
31
 
32
+ ```
33
+ ## 知りたいこと
34
+ ・リワード広告を呼び出すたびに違う広告を表示して試聴時間が一定時間経過するとポイントが付与される実装が知りたいです。
35
+ ```
36
+
32
37
  詳しい方いましたらアドバイスお願いいたします。