有没有办法允许用户在使用另一个应用程序的同时下载和安装一个 iOS 应用程序,并在该应用程序下载并可用后收到通知?
问题:
我有一个应用程序(比如 App1),我想检查设备中是否有另一个应用程序(比如 App2)。如果 App2 不可用,我需要从 iTunes 下载。下载完成后,我需要提醒用户 App2 下载已完成并可以使用。
我试图搜索一个 iTunes API 来执行此操作,但我没有找到任何东西。
最佳答案
唯一的解决方案是尝试从 App1 打开 App2 中指定的 URL Scheme。并从 App1 不断地轮询直到找到它。
对象
- (void)checkForSiblingApp {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"<app2scheme>://"]]) {
//App exists! Show user a message and then call this to open the app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"<app2scheme>://"]];
} else {
//App does not exist, check again in 1 minute
[self performSelector:@selector(checkForSiblingApp) withObject:nil afterDelay:60];
}
}
swift
func checkForSiblingApp() {
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "<app2scheme>://")!) {
//App exists! Show user a message and then call this to open the app
UIApplication.sharedApplication().openURL(NSURL(string: "<app2scheme>://")!)
} else {
//App does not exist, check again in 1 minute
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(60 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
self.checkForSiblingApp()
}
}
}
这会告诉您您的应用程序在设备上是否可用。这是应用间通信,您可以阅读更多 here .
关于ios - 下载 iOS 应用程序并在下载完成后收到通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31320237/