如何當(dāng)我們的app檢查到有更新的時(shí)候通過(guò)itms-service協(xié)議 系統(tǒng)就會(huì)彈出一個(gè)系統(tǒng)級(jí)別的UIAlertView(就算APP死了彈窗還在),點(diǎn)擊確定之后就是APP terminate by signal 9 自動(dòng)退出萤悴,開(kāi)始更新APP漠吻。
BUTJ拭场佛析!
在iOS11.2 并不是這樣的 點(diǎn)擊確定之后彈窗是消失了挨摸,APP不會(huì) 自動(dòng)退出诲宇。就傻傻的沒(méi)反應(yīng)际歼。也不會(huì)開(kāi)始更新的動(dòng)作,只有通過(guò)點(diǎn)擊Home鍵和殺死APP姑蓝,退到后臺(tái)鹅心,更新程序才開(kāi)始運(yùn)行。
我在百度和簡(jiǎn)書(shū)一直搜索不到相似的文章纺荧,蘋(píng)果開(kāi)發(fā)論壇可以搜索到有人也遇到相同的事情旭愧,卻沒(méi)有附上解決辦法。
1.itms-service 協(xié)議
蘋(píng)果好像已撤掉文檔了宙暇。
2.監(jiān)聽(tīng)UIAlertView
系統(tǒng)級(jí)別的無(wú)法監(jiān)聽(tīng)到,stackOverFlow也有人跟我一樣的想法输枯。給出另外的辦法,親測(cè)不行占贫。
https://stackoverflow.com/questions/27652416/itms-services-protocol-get-click-result-cancel-or-install
3.讓APP自動(dòng)退出
可以調(diào)用exit(0) 直接殺死app桃熄。但是如果用戶選擇了取消更新,就不應(yīng)該退出APP型奥。
4.私有API
查下有什么強(qiáng)大的API可以幫到我們瞳收。
查了2天終于在一篇文章找到解決
https://stackoverflow.com/questions/25913834/ios-8-openurl-itms-services-does-not-exit-current-app
While forcing the app to crash will technically work, a much better solution (allowing the user to retain the state of the application) would be to simply background the app launching the itms-services link by executing the following.
[[UIApplication sharedApplication] performSelector:@selector(suspend)];
We use this in an app used for distributing test builds to our testers and it works very well, and eliminates the confusion of a tester trying to install an app and having the app stay in front. It also allows them to return to our distribution app and have it pick up where they were.
打開(kāi)更新彈窗之后,讓程序自己推到后臺(tái)厢汹,不是殺死APP螟深。
如果用戶選擇了確定更新,就會(huì)開(kāi)始更新烫葬。
如果用戶選擇了取消界弧,那用戶也可以從后臺(tái)恢復(fù)APP。
總算解決問(wèn)題搭综,因?yàn)槭欠职l(fā)企業(yè)版垢箕,無(wú)所謂調(diào)用私有API