Booking.com如何以编程方式关闭其应用程序? [英] How does Booking.com close their app programmatically?
问题描述
我刚刚看到Booking.com应用程序执行此操作的技巧,可让您更改应用程序的语言:
I just saw this trick the Booking.com app does to let you change the application's language:
我不知道有什么技术可以以编程方式关闭iOS应用程序(Apple的准则也禁止这样做,但让我们假装"老板希望我这样做).
I'm not aware of any technique to programmatically close an iOS app (and it's also forbidden by Apple's guidelines, but let's "pretend" that my boss wants me to do this).
他们是如何做到的?我尝试了exit(0)
,但是它立即退出,就像进程崩溃时一样,而他们的应用通常会自动显示在主屏幕上.可能有打开主屏幕的私有URL方案吗?
How do they do it? I've tried exit(0)
but it immediately quit like when the process crashes, while their app animates to the home screen normally. Is there maybe a private URL scheme that opens the home screen?
推荐答案
您可以尝试
// after change language dim display and follow it with this snippet
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
UIApplication.shared.perform(#selector(NSXPCConnection.suspend))
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
exit(0)
}
}
在类似情况下,我已经做了很多次,并且应用程序被接受而没有拒绝
I have done it many times in similar cases and the app accepted without rejection
这篇关于Booking.com如何以编程方式关闭其应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!