IOS App Launch Option

Source: Internet
Author: User

Application:didfinishlaunchingwithoptions is always called when the IOS program starts: The second parameter is launchoptions an object of type Nsdictionary, which stores the reason for this program to start.

see the possible key values in the Launchoptions uiapplication Class Reference The launch Options keys section.

  • If the user launches directly, no data in the lauchoptions;

  • if the other application passes OpenURL: start, the Uiapplicationlaunchoptionsurlkey corresponding object is the boot URL (nsurl), Uiapplicationlaunchoptionssourceapplicationkey the bundle ID of the source application that corresponds to the startup (NSString);

  • if initiated by a local notification, the Uiapplicationlaunchoptionslocalnotificationkey corresponds to the local notification object for the startup application (uilocalnotification );

  • If initiated by a remote notification, the Uiapplicationlaunchoptionsremotenotificationkey corresponds to the remote notification information userinfo (nsdictionary) that initiates the application;

  • Other keys also have Uiapplicationlaunchoptionsannotationkey,uiapplicationlaunchoptionslocationkey,
    Uiapplicationlaunchoptionsnewsstanddownloadskey.

If you want to make some distinctions at startup, you need to do this in the code below.

For example: Your app can be picked up by some other app (as a sub-app for that app), and to achieve a single sign-on, you need to make a reasonable verification in the boot code and skip the login.

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
{
Nsurl *url = [Options Objectforkey:uiapplicationlaunchoptionsurlkey];
if (URL)
{
}
NSString *bundleid = [Options Objectforkey:uiapplicationlaunchoptionssourceapplicationkey];
if (Bundleid)
{
}
Uilocalnotification * localnotify = [options Objectforkey:uiapplicationlaunchoptionslocalnotificationkey];
if (localnotify)
{
}
Nsdictionary * userInfo = [options Objectforkey:uiapplicationlaunchoptionsremotenotificationkey];
if (userInfo)
{
}

}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.