質問編集履歴

1

コードの追加を致しました

2023/05/24 07:50

投稿

tactaco
tactaco

スコア15

test CHANGED
File without changes
test CHANGED
@@ -25,21 +25,47 @@
25
25
 
26
26
  ※製品IDは例としてわかりやすく変えてあります。
27
27
  ```ここに言語名を入力
28
+ ---KakinView.swift---
29
+ テーブルビューがあるページとなります。
30
+ var paymentManager:PaymentManager!
31
+ var productRequest:SKProductsRequest?
32
+ var products: Array<SKProduct>?
33
+
34
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
35
+
36
+ let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
37
+ cell.textLabel?.text = products?[indexPath.row].localizedTitle
38
+ return cell
39
+ }
40
+
41
+ ---ProductManager.swift---
28
42
  製品IDの設定
29
-  func productIds() -> Set<String> {
43
+   func productIds() -> Set<String> {
30
44
  return Set(arrayLiteral:
31
45
  "プラン1",
32
46
  "プラン2",
33
47
  "プラン3"
34
48
  )
49
+
35
- セルの中身
50
+ ---PaymentManager.swift---
36
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
51
+ func startProductRequest(_ productIds:Set<String>) -> SKProductsRequest {
37
-
52
+ print("リクエストがスタートされました1")
38
- let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
53
+ let productsRequest = SKProductsRequest(productIdentifiers: productIds)
39
- cell.textLabel?.text = products?[indexPath.row].localizedTitle
54
+ productsRequest.delegate = self
40
-
55
+ productsRequest.start()
41
- return cell
56
+ return productsRequest
42
57
  }
58
+
59
+ // プロダクト情報の取得が成功したときに呼び出される
60
+ public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
61
+ // invalidProductIdentifiersがあればログに出力する
62
+ for invalidIds in response.invalidProductIdentifiers {
63
+ print(invalidIds)
64
+ }
65
+ delegate?.finishRequest(request, products:response.products)
66
+ }
67
+
68
+
43
69
  ```
44
70
 
45
71
  ### 試したこと