MSDistributeDelegate分发方法未被调用。

问题描述 投票:0回答:1

这是我的AppDelegate。

import UIKit
import AppCenter
import AppCenterDistribute
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, MSDistributeDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        MSDistribute.setDelegate(self)
        MSAppCenter.start("...", withServices: [MSDistribute.self])

        return true
    }

    func distribute(_ distribute: MSDistribute!, releaseAvailableWith details: MSReleaseDetails!) -> Bool {

         // Your code to present your UI to the user, e.g. an UIAlertController.
         let alertController = UIAlertController(title: "Update available.",
                                               message: "Do you want to update?",
                                        preferredStyle:.alert)

         alertController.addAction(UIAlertAction(title: "Update", style: .cancel) {_ in
           MSDistribute.notify(.update)
         })

         alertController.addAction(UIAlertAction(title: "Postpone", style: .default) {_ in
           MSDistribute.notify(.postpone)
         })

         // Show the alert controller.
         self.window?.rootViewController?.present(alertController, animated: true)
         return true;
       }

}

所以,当我用这段代码制作比如说build 1,然后发布一个新的build给Contributors(或内部或公共测试人员组),当他们试图打开他们当前的应用程序(build 1)时,这段代码不会运行。

我已经按照App Center的例子来处理这个问题,除此之外,我还把这个添加到了我的info.plist中。

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>"appcenter-..."</string>
    </array>
  </dict>
</array>

但是什么都没有发生 我是不是不明白这应该如何工作?我认为浏览器应该打开一个链接,将我们带到更新页面,然后我们返回到更新的应用程序。

我是不是遗漏了什么?如何调试这个问题?

ios swift fastlane
1个回答
0
投票

如果你的delegate方法没有被调用,可能有几个原因。

  1. 检查你的框架版本(有时框架会有一些问题)
  2. 检查你的appcenter秘钥,因为该秘钥应该是正确的格式,例如:appcenter-XXXX-XXXX-XXXX (从appcenter网站复制秘钥并粘贴到你的代码中)

    @available(iOS 11.0, *)extension AppDelegate: MSDistributeDelegate {

    private func initializeAppCenterSDK() {
        #if DEBUG
        MSAppCenter.start(appCenterSecretKey, withServices:[MSCrashes.self])
        #else
        MSDistribute.updateTrack = .private
        MSDistribute.setDelegate(self)
        MSAppCenter.start(appCenterSecretKey, withServices:[MSCrashes.self, MSDistribute.self])
        #endif
    }
    
    func distribute(_ distribute: MSDistribute!, releaseAvailableWith details: MSReleaseDetails!) -> Bool {
        //TODO: Need to localized
        Logger.info(" \(#function) Distribute method called ankit ", category: .chatFlow)
        let alertController = UIAlertController(title: "Update available for UCC.", message: "Do you want to update?", preferredStyle:.alert)
        alertController.addAction(UIAlertAction(title: "Update", style: .cancel) {_ in
            MSDistribute.notify(.update)
        })
        alertController.addAction(UIAlertAction(title: "Postpone", style: .default) {_ in
            MSDistribute.notify(.postpone)
        })
    
        self.window?.rootViewController?.present(alertController, animated: true)
        return true;
    }
    

    }

app update popup

© www.soinside.com 2019 - 2024. All rights reserved.