How to trigger Core Bluetooth state preservation and restoration

前端 未结 2 955
眼角桃花
眼角桃花 2020-12-14 12:35

State Preservation and Restoration Because state preservation and restoration is built in to Core Bluetooth, your app can opt in to this feature to ask th

2条回答
  •  盖世英雄少女心
    2020-12-14 13:15

    Just figured this out recently with the help of Apple Tech. Also given/have a nice link that shows the different ways to cause the app to restart without user intervention.

    I did it by causing the app to crash suddenly with the following snippet of swift code. This causes the app to restart and the call the 'willRestoreState' callback.

    DispatchQueue.main.asyncAfter(deadline: .now() + 5)
            {
                print("Killing app")
                // CRASH
                if ([0][1] == 1){
                    exit(0)
                }
                exit(1)
            }
    

提交回复
热议问题