Jump and transfer issues between apps

Source: Internet
Author: User

Jump and transfer between apps;

First create 2 app Formapp (need to jump to another app) Toapp (the item to be jumped)

One: Operations in the Toapp project:

1: Create Urlschemes, (1). Open the Info.plist file,

2. In the APPDELEGATE.M
-(BOOL) Application: (UIApplication *) app OpenURL: (nsurl *) URL options: (nsdictionary< Uiapplicationopenurloptionskey,ID> *) options{/** If you use URL to pass parameters*/NSLog (@"----formapp_url:%@", URL); /** If you are using a shear plate to pass the parameters,*/Uipasteboard*pasteboard =[Uipasteboard Generalpasteboard]; NSString*content = pasteboard.string; NSLog (@"Shear Plate Get Parameters:%@", content); /** Other Operations*/        returnYES;}

Second: operation in the Formapp

1. Check whether the device has Toapp installed and jump
/** Jump Action*/- (void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event{    /** Toapp schemes://*/NSString*toappschemes =@"willtoappurlschemes://"; /** Check whether the device is installed Toapp*/    if([[[UIApplication sharedapplication] Canopenurl:[nsurl Urlwithstring:toappschemes]] {NSLog (@"alearly Install"); /** Jump App*/                /** 1: Pass parameters using URL*/        if([self IOS10]) {[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:[nsstring str Ingwithformat:@"%@?usrid=110", Toappschemes]] options:@{} completionhandler:^(BOOL success) {/** operation after successful jump*/            }]; }Else{[[uiapplication sharedapplication] Openurl:[nsurl urlwithstring:[nsstring stringWithFormat:@"%@?usrid=110", Toappschemes]]; }                //        /**//2: Passing Parameters using the Clipboard//         *///[[uiapplication sharedapplication] Canopenurl:[nsurl Urlwithstring:toappschemes]];//        /**//system Clipboard (empty when parameters are accepted in Topapp)//         *///Uipasteboard *pasteboard = [Uipasteboard Generalpasteboard];//pasteboard.string = @ "user=120&orderid=123456";            }Else{NSLog (@"Not install"); }}/** Determine if the system is greater than ten*/-(BOOL) ios10{return([[[[Uidevice Currentdevice] systemversion] floatvalue]) >=Ten?Yes:no;}

2: Note that you need to set up a whitelist after Xcode7 and iOS9 to detect if it is installed,

Open Formapp info.plist file, add Lsapplicationqueriesschemes

This will allow you to successfully detect if the Toapp is installed.

3. In the way of passing parameters in addition to the URL, clipboard, and keychain, and so on, want to know more ways or detailed, can search--app communication between

Jump and transfer issues between apps

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.