Download the iOS app and get notified when the download is complete.

Is there a way to allow the user to download and install the iOS application when using another application and receive a notification after the application is downloaded and available for use?

Problem:

I have an application (say, App1) and I want to check if another application is available on the device (say, App2). If App2 is not available, I need to download from itunes. After the download is complete, I need to warn the user that the download of App2 has been completed and is available for use.

I tried to find the iTunes API for this, but found nothing.

+4
source share
1 answer

- URL-, App2 App1. App1, .

ObjC

- (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()
        }
    }
}

, . Inter-App Communication, .

+3

All Articles