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

質問編集履歴

5

参考URLから再構築した結果を更新

2017/07/20 10:33

投稿

midomurasaki
midomurasaki

スコア46

title CHANGED
File without changes
body CHANGED
@@ -11,37 +11,219 @@
11
11
  スクリーンショット(左:実機, 右:シミュレーター)
12
12
  ![実機](3281add15973a8a5e9e39e056f9e7763.png) ![シミュレーター](a3067fe5bc71a90754a1bb4e1a9cf013.png)
13
13
 
14
+ 実機ログ(2017/07/20 19:40編集 文字超過のため削除)
15
+
16
+
17
+
18
+
19
+
20
+ Build Settings>Linking>Other Linker Flagsに-ObjCがあるか確認しましたが、最初から入力済でした。
21
+ info.plistのATSでHTTP通信を許可してみても変化なしです。
22
+
23
+ 追加
24
+ Firebaseのバージョンを3.8.0などに落としてみたりしましたがだめでした。
25
+
26
+ ログの内容で色々とググってみましたが解決に至らず、解決方法をご存知でしたらご教示ください。
27
+
28
+
29
+
30
+
31
+ #2017/07/20 19:40追記
32
+ [https://i-app-tec.com/ios/rewarded-video-ads.html](https://i-app-tec.com/ios/rewarded-video-ads.html)
33
+ こちらの内容で再度試してみました。
34
+ サンプルコードのプロジェクトに新しくViewControllerを追加しています。
35
+ が、やはりシミュレーターでは再生OKで実機ではダメでした。
36
+
37
+ ```swift
38
+ import Firebase
39
+ import UIKit
40
+
41
+ @UIApplicationMain
42
+ class AppDelegate: UIResponder, UIApplicationDelegate {
43
+
44
+ var window: UIWindow?
45
+
46
+ func application(_ application: UIApplication,
47
+ didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
48
+ // Use Firebase library to configure APIs
49
+ FirebaseApp.configure()
50
+ // Initialize Google Mobile Ads SDK
51
+ GADMobileAds.configure(withApplicationID: "ca-app-pub-3940256099942544~1458002511")
52
+
53
+ return true
54
+ }
55
+
56
+ }
57
+ ```
58
+
59
+ ```swift
60
+ import UIKit
61
+ import GoogleMobileAds
62
+
63
+ class AdmobViewController: UIViewController, GADRewardBasedVideoAdDelegate {
64
+
65
+ // let AdMobID = "[Your AdMob ID]"
66
+ let TEST_ID = "ca-app-pub-3940256099942544/1712485313"
67
+ var AdUnitID:String? = nil
68
+
69
+ // let simulation = true
70
+
71
+ /// Is an ad being loaded.
72
+ var adRequestInProgress = false
73
+ var adRedy = false
74
+
75
+ /// The reward-based video ad.
76
+ var rewardBasedVideo: GADRewardBasedVideoAd?
77
+
78
+ // Button to show AdMob
79
+ @IBOutlet weak var playAd: UIButton!
80
+
81
+ @IBOutlet weak var statusLabel: UILabel!
82
+
83
+
84
+ override func viewDidLoad() {
85
+ super.viewDidLoad()
86
+
87
+ // if simulation {
88
+ AdUnitID = TEST_ID
89
+ // }
90
+ // else{
91
+ // AdUnitID = AdMobID
92
+ // }
93
+
94
+ rewardBasedVideo = GADRewardBasedVideoAd.sharedInstance()
95
+ rewardBasedVideo?.delegate = self
96
+
97
+ setupRewardBasedVideoAd()
98
+
99
+ }
100
+
101
+ func setupRewardBasedVideoAd(){
102
+ statusLabel.text = "set up"
103
+
104
+ if !adRequestInProgress && rewardBasedVideo?.isReady == false {
105
+ rewardBasedVideo?.load(GADRequest(),
106
+ withAdUnitID: AdUnitID! )
107
+
108
+ adRequestInProgress = true
109
+ }
110
+ else{
111
+ print("Error: setup RewardBasedVideoAd")
112
+ }
113
+ }
114
+
115
+ @IBAction func playAd(_ sender: AnyObject) {
116
+ print("adRedy=\(adRedy)")
117
+
118
+ if GADRewardBasedVideoAd.sharedInstance().isReady && adRedy{
119
+ GADRewardBasedVideoAd.sharedInstance().present(fromRootViewController: self)
120
+ adRedy = false
121
+ }
122
+ else{
123
+ print("Error: Reward based video not ready")
124
+ }
125
+ }
126
+
127
+ // MARK: GADRewardBasedVideoAdDelegate implementation
128
+ func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
129
+ didFailToLoadWithError error: Error) {
130
+ adRequestInProgress = false
131
+ statusLabel.text = "failed to load"
132
+
133
+ print("Reward based video ad failed to load: \(error.localizedDescription)")
134
+ }
135
+
136
+ func rewardBasedVideoAdDidReceive(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
137
+ statusLabel.text = "ad is received"
138
+ adRequestInProgress = false
139
+ adRedy = true
140
+
141
+ print("Reward based video ad is received.")
142
+ }
143
+
144
+ func rewardBasedVideoAdDidOpen(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
145
+ statusLabel.text = "Opened reward based video ad."
146
+
147
+ print("Opened reward based video ad.")
148
+ }
149
+
150
+ func rewardBasedVideoAdDidStartPlaying(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
151
+ print("started playing.")
152
+ }
153
+
154
+ func rewardBasedVideoAdDidClose(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
155
+ statusLabel.text = "ad is closed"
156
+ setupRewardBasedVideoAd()
157
+
158
+ print("Reward based video ad is closed.")
159
+ }
160
+
161
+ func rewardBasedVideoAdWillLeaveApplication(_ rewardBasedVideoAd: GADRewardBasedVideoAd) {
162
+
163
+ print("Reward based video ad will leave application.")
164
+ }
165
+
166
+ func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
167
+ didRewardUserWith reward: GADAdReward) {
168
+ print("Reward received with currency: \(reward.type), amount \(reward.amount).")
169
+ }
170
+
171
+
172
+
173
+ override func didReceiveMemoryWarning() {
174
+ super.didReceiveMemoryWarning()
175
+ // Dispose of any resources that can be recreated.
176
+ }
177
+
178
+
179
+ }
180
+
181
+ ```
182
+
14
183
  実機ログ
15
184
  ```
16
- 2017-07-19 20:57:35.608225+0900 RewardedVideoExample[13066:1335184] [DYMTLInitPlatform] platform initialization successful
17
- 2017-07-19 20:57:35.901290+0900 RewardedVideoExample[13066:1335188] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40002000 started
18
- 2017-07-19 20:57:35.901 RewardedVideoExample[13066] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40002000 started
19
- 2017-07-19 20:57:35.901893+0900 RewardedVideoExample[13066:1335188] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
20
- 2017-07-19 20:57:35.902 RewardedVideoExample[13066] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
21
- 2017-07-19 20:57:36.254744+0900 RewardedVideoExample[13066:1335178] [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
22
- 2017-07-19 20:57:36.255 RewardedVideoExample[13066] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
23
- 2017-07-19 20:57:36.255921+0900 RewardedVideoExample[13066:1335178] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
24
- 2017-07-19 20:57:36.256 RewardedVideoExample[13066] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
25
- 2017-07-19 20:57:36.370997+0900 RewardedVideoExample[13066:1335107] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
26
- 2017-07-19 20:57:36.371934+0900 RewardedVideoExample[13066:1335107] [MC] Reading from public effective user settings.
27
- 2017-07-19 20:57:36.469236+0900 RewardedVideoExample[13066:1335178] [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
28
- 2017-07-19 20:57:36.494 RewardedVideoExample[13066] <Notice> [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
29
- 2017-07-19 20:57:36.667838+0900 RewardedVideoExample[13066:1335204] TIC Read Status [1:0x0]: 1:57
30
- 2017-07-19 20:57:36.669378+0900 RewardedVideoExample[13066:1335204] TIC Read Status [1:0x0]: 1:57
31
- 2017-07-19 20:57:36.847209+0900 RewardedVideoExample[13066:1335193] <Google> Cannot find an ad network adapter with the name(s): com.google.DummyAdapter. Remember to link all required ad network adapters and SDKs, and set -ObjC in the 'Other Linker Flags' setting of your build target.
185
+ 2017-07-20 19:21:10.786265+0900 RewardedVideoExample[17506:1685024] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40002000 started
186
+ 2017-07-20 19:21:10.787 RewardedVideoExample[17506] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40002000 started
187
+ 2017-07-20 19:21:10.789715+0900 RewardedVideoExample[17506:1685024] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
188
+ 2017-07-20 19:21:10.791 RewardedVideoExample[17506] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
189
+ 2017-07-20 19:21:11.714092+0900 RewardedVideoExample[17506:1684957] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
190
+ 2017-07-20 19:21:11.716054+0900 RewardedVideoExample[17506:1684957] [MC] Reading from public effective user settings.
191
+ 2017-07-20 19:21:12.132385+0900 RewardedVideoExample[17506:1685033] TIC Read Status [1:0x0]: 1:57
192
+ 2017-07-20 19:21:12.132457+0900 RewardedVideoExample[17506:1685033] TIC Read Status [1:0x0]: 1:57
193
+ 2017-07-20 19:21:12.364643+0900 RewardedVideoExample[17506:1685066] [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
194
+ 2017-07-20 19:21:12.366 RewardedVideoExample[17506] <Notice> [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
195
+ 2017-07-20 19:21:12.420720+0900 RewardedVideoExample[17506:1685066] [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
196
+ 2017-07-20 19:21:12.421 RewardedVideoExample[17506] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
197
+ 2017-07-20 19:21:12.422509+0900 RewardedVideoExample[17506:1685066] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
198
+ 2017-07-20 19:21:12.422 RewardedVideoExample[17506] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
199
+ 2017-07-20 19:21:12.507906+0900 RewardedVideoExample[17506:1685028] <Google> Cannot find an ad network adapter with the name(s): com.google.DummyAdapter. Remember to link all required ad network adapters and SDKs, and set -ObjC in the 'Other Linker Flags' setting of your build target.
32
200
  Reward based video ad failed to load: No ad returned from any ad server.
201
+ 2017-07-20 19:21:27.199211+0900 RewardedVideoExample[17506:1685066] TIC Read Status [5:0x0]: 1:57
202
+ 2017-07-20 19:21:27.199416+0900 RewardedVideoExample[17506:1685066] TIC Read Status [5:0x0]: 1:57
33
- 2017-07-19 20:57:50.929078+0900 RewardedVideoExample[13066:1335107] API error: (null) returned 0 width, assuming UIViewNoIntrinsicMetric
203
+ 2017-07-20 19:21:27.202074+0900 RewardedVideoExample[17506:1685066] [Firebase/Analytics][I-ACS023130] Configuration not found. Using default configuration
204
+ 2017-07-20 19:21:27.202 RewardedVideoExample[17506] <Warning> [Firebase/Analytics][I-ACS023130] Configuration not found. Using default configuration
34
- 2017-07-19 20:57:50.929178+0900 RewardedVideoExample[13066:1335107] API error: (null) returned 0 width, assuming UIViewNoIntrinsicMetric
205
+ 2017-07-20 19:21:27.420460+0900 RewardedVideoExample[17506:1685157] TIC Read Status [6:0x0]: 1:57
206
+ 2017-07-20 19:21:27.420599+0900 RewardedVideoExample[17506:1685157] TIC Read Status [6:0x0]: 1:57
207
+ adRedy=false
208
+ Error: Reward based video not ready
35
209
 
36
210
  ```
37
211
 
38
212
 
213
+ ```swift
214
+ func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
215
+ didFailToLoadWithError error: Error) {
216
+ adRequestInProgress = false
217
+ statusLabel.text = "failed to load"
39
218
 
219
+ print("Reward based video ad failed to load: \(error.localizedDescription)")
220
+ }
221
+ ```
222
+ からは
223
+ ```
224
+ Reward based video ad failed to load: No ad returned from any ad server.
225
+ ```
226
+ と返ってきます。
227
+ なお、自分で作成したプロジェクト上で、ApplicationIDとGoogleService-Info.plistをFirebaseより生成したもので実行しても結果は同じです。
40
228
 
41
- ```Build Settings```>```Linking```>```Other Linker Flags```に```-ObjC```があるか確認しましたが、最初から入力済でした。
42
- ```info.plist```のATSでHTTP通信を許可してみても変化なしです。
43
-
44
- 追加
45
- Firebaseのバジョンを3.8.0など落としてみたしたがだめでした
229
+ シミュレターではできるの実機で出来ない理由がわかりません。。
46
-
47
- ログの内容で色々とググってみましたが解決に至らず、解決方法をご存知でしたらご教示ください。

4

サンプルのファイルパス追加

2017/07/20 10:33

投稿

midomurasaki
midomurasaki

スコア46

title CHANGED
File without changes
body CHANGED
@@ -1,7 +1,10 @@
1
1
  AdMobのリワード動画を実装しようとしています。
2
2
 
3
3
  googleが提供しているサンプルを[こちら](https://github.com/googleads/googleads-mobile-ios-examples)からダウンロードし、```pod install```、```pod update```をした上でシミュレーター上で実行すると問題無く動画が再生されます。
4
+
4
5
  サンプルURL:[https://github.com/googleads/googleads-mobile-ios-examples](https://github.com/googleads/googleads-mobile-ios-examples)
6
+ ファイル: ```googleads-mobile-ios-examples-master/Swift/admob/RewardedVideoExample/RewardedVideoExample.xcworkspace```
7
+
5
8
  ですが、実機で実行するとエラーのアラートとログが出力され、動画が再生できません。
6
9
 
7
10
 

3

表示の不具合を修正

2017/07/20 08:33

投稿

midomurasaki
midomurasaki

スコア46

title CHANGED
File without changes
body CHANGED
@@ -34,9 +34,11 @@
34
34
 
35
35
 
36
36
 
37
+
37
38
  ```Build Settings```>```Linking```>```Other Linker Flags```に```-ObjC```があるか確認しましたが、最初から入力済でした。
38
39
  ```info.plist```のATSでHTTP通信を許可してみても変化なしです。
40
+
39
41
  追加
40
- ```Firebase```のバージョンを3.8.0などに落としてみたりしましたがだめでした。
42
+ Firebaseのバージョンを3.8.0などに落としてみたりしましたがだめでした。
41
43
 
42
44
  ログの内容で色々とググってみましたが解決に至らず、解決方法をご存知でしたらご教示ください。

2

表示がおかしい部分を修正

2017/07/20 08:28

投稿

midomurasaki
midomurasaki

スコア46

title CHANGED
File without changes
body CHANGED
@@ -1,7 +1,7 @@
1
1
  AdMobのリワード動画を実装しようとしています。
2
2
 
3
3
  googleが提供しているサンプルを[こちら](https://github.com/googleads/googleads-mobile-ios-examples)からダウンロードし、```pod install```、```pod update```をした上でシミュレーター上で実行すると問題無く動画が再生されます。
4
- サンプルURL:[h![イメージ説明](ee85a044508a784b8b83e3e73b280d2e.png)/github.com/googleads/googleads-mobile-ios-examples](https://github.com/googleads/googleads-mobile-ios-examples)
4
+ サンプルURL:[https://github.com/googleads/googleads-mobile-ios-examples](https://github.com/googleads/googleads-mobile-ios-examples)
5
5
  ですが、実機で実行するとエラーのアラートとログが出力され、動画が再生できません。
6
6
 
7
7
 

1

サンプルのURLを直接表示し、シミュレーターのスクリーンショットと試したことを追加

2017/07/20 08:26

投稿

midomurasaki
midomurasaki

スコア46

title CHANGED
File without changes
body CHANGED
@@ -1,11 +1,12 @@
1
1
  AdMobのリワード動画を実装しようとしています。
2
2
 
3
3
  googleが提供しているサンプルを[こちら](https://github.com/googleads/googleads-mobile-ios-examples)からダウンロードし、```pod install```、```pod update```をした上でシミュレーター上で実行すると問題無く動画が再生されます。
4
+ サンプルURL:[h![イメージ説明](ee85a044508a784b8b83e3e73b280d2e.png)/github.com/googleads/googleads-mobile-ios-examples](https://github.com/googleads/googleads-mobile-ios-examples)
4
5
  ですが、実機で実行するとエラーのアラートとログが出力され、動画が再生できません。
5
6
 
6
7
 
7
- スクリーンショット
8
+ スクリーンショット(左:実機, 右:シミュレーター)
8
- ![イメージ説明](3281add15973a8a5e9e39e056f9e7763.png)
9
+ ![実機](3281add15973a8a5e9e39e056f9e7763.png) ![シミュレーター](a3067fe5bc71a90754a1bb4e1a9cf013.png)
9
10
 
10
11
  実機ログ
11
12
  ```
@@ -35,5 +36,7 @@
35
36
 
36
37
  ```Build Settings```>```Linking```>```Other Linker Flags```に```-ObjC```があるか確認しましたが、最初から入力済でした。
37
38
  ```info.plist```のATSでHTTP通信を許可してみても変化なしです。
39
+ 追加
40
+ ```Firebase```のバージョンを3.8.0などに落としてみたりしましたがだめでした。
38
41
 
39
42
  ログの内容で色々とググってみましたが解決に至らず、解決方法をご存知でしたらご教示ください。