0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Siren Error] Error parsing App Store JSON data でハマった話

Posted at

Sirenは現在積極的なアップデートが停止され、read-onlyとしてメンテナンスはしばらく続けるという状態になっている。iOSネイティブの iTunes API を使ったアップデート通知の受け取り方法もあるが、現状まだSirenを使いたい。

表題のエラーがいつからか出るようになったので、Sirenを最新の6.1.3にアップデートするも以前治らない。

原因は Debug と Release で Bundle Identifier を分けるように変わったこと。

スクリーンショット 2025-05-13 20.43.38.png

そのため、APIManagerの初期化時に明示的に bundleID を引数で指定しないといけないということだった。

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        // https://github.com/ArtSabintsev/Siren/blob/master/Example/Example/AppDelegate.swift
        // Production の App Store 最新リリースから1日以上経っていないと通知されない仕様
        // App Store の段階的なリリースを使用する場合はカスタマイズが必要
        let siren = Siren.shared
        siren.apiManager = APIManager(country: .japan, language: "ja_jp", bundleID: "reright.yachogo") // デフォルトでは local は .debug になるため
        siren.rulesManager = RulesManager(globalRules: .persistent)
        siren.presentationManager = PresentationManager(
            updateButtonTitle: "今すぐアップデート",
            nextTimeButtonTitle: "後で"
        )

        siren.wail { results in
            print("Siren results: \(results)")
            switch results {
            case .success(let updateResults):
                print("AlertAction ", updateResults.alertAction)
                print("Localization ", updateResults.localization)
                print("Model ", updateResults.model)
                print("UpdateType ", updateResults.updateType)
            case .failure(let error):
                print(error.localizedDescription)
            }
        }
    }

なお、5系では

siren.apiManager = APIManager(countryCode: "JP")

を使用していたが、bundleIDを指定する初期化関すは APIManager(country:, language?:, bundleID?:) しかないようで、READMEやリポジトリ内に記載がないが language コードはデフォルトが en_us なので ja_jp が正しい模様。

余談

The app has been released for 0 days, but Siren cannot prompt the user until 1 days have passed.

ローカルでテストしようとすると上記エラーが出ることがあるが、エラー文の通り Siren は最新アプリの App Store 上のリリースから1日経ってないと通知されないので、1日待つ必要がある(最近英語がなんか読めない)。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?