IOS Launcher 4 ways, as well as allies push in the foreground without pushing, and the status of the current program

Source: Internet
Author: User

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

Description: When the application starts, the application launches the portal. Executes only once when the application starts. The application parameter is used to obtain the state, variable, etc. of the application, and it is worth noting the dictionary parameter: (nsdictionary *) launchoptions, which stores the reason for the program to start.

1. If the user starts directly, no data is in the lauchoptions;
2. If the other application through OpenURL: Start, then the Uiapplicationlaunchoptionsurlkey corresponding object is the boot URL (nsurl), Uiapplicationlaunchoptionssourceapplicationkey the bundle ID of the source application that corresponds to the startup (NSString);

3. If initiated by local notification, the Uiapplicationlaunchoptionslocalnotificationkey corresponds to the local notification object (uilocalnotification) for the launch application;

4. If initiated by 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, an 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 reasonable authentication 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)
{
}
}

According to the current program status, determine whether the current program is pushed (foreground does not push, background push)

-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo{

[Umessage Didreceiveremotenotification:userinfo];

Customizing the Popup Box

if ([uiapplication sharedapplication].applicationstate = = uiapplicationstateactive) {//program is active, push not allowed

[Umessage setautoalert:no];//close the Prompt box

}else{//Allow push

[Umessage Didreceiveremotenotification:userinfo];

Send Notifications

Nsnotificationcenter *center = [Nsnotificationcenter defaultcenter];

Send remote Notifications

[Center postnotificationname:@ "Cyremotenotication" Object:nil Userinfo:userinfo];

}

}

IOS Launcher 4 ways, as well as allies push in the foreground without pushing, and the status of the current program

Related Article

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.