1. Open Other applications
Appurlstr = "cwork://app_id?title=xxx&content=xxx"
[[uiapplication sharedapplication] openURL: [nsurl urlwithstring: APPURLSTR]];
- Requires the other app to be configured in Info.pist:
This allows the other application to be tuned.
2. Opened by other applications
(1) as shown, need to configure themselves in the Info.plist, others fall themselves, where identifer no use, mainly the URL schemes, it will be used to splice the URL of the transfer: such as: Cwork://xx-id?parame1 = "1" & Parame2= "2"
A, when the program is already running, it will arouse the agent in Appdelegate:
#define CWORKURLSCHEML @ "cwork://"-(BOOL) Application: (UIApplication *) application Handleopenurl: (Nsurl *) url{ if (!url) { return NO; } NSString *urlstring = [url absolutestring]; Listen for who is tuned if ([urlstring rangeofstring:cworkurlscheml].length > 0) { } return YES;}
B. When the program is first started:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { Nsurl *alaunchoptionsurl = [Launchoptions Objectforkey:uiapplicationlaunchoptionsurlkey]; Wake-up monitoring by other application, parsing if ([alaunchoptionsurl.absolutestring hasprefix:cworkurlscheml]) { }return YES;}
(2) then the URL with parameters, you can parse the URL to "?" As a delimiter, parse the arguments on both sides
+ (Nsdictionary *) Urlpropertyvalue: (NSString *) aurlstr{ nsarray *alist = [Aurlstr componentsseparatedbystring:@ "?"]; if (Alist.count < 2) { return nil; } Nsmutabledictionary *adict = [nsmutabledictionary dictionary]; NSString *rootpath = [alist objectatindex:0]; [Adict setobject:rootpath forkey:@ "RootPath"]; NSString *avaluestr = [alist objectatindex:1]; Nsarray *alist1 = [avaluestr componentsseparatedbystring:@ "&"]; For (NSString *astr in aList1) { Nsarray *l = [aStr componentsseparatedbystring:@ "="]; if (L.count = = 2) { nsstring *k = [L objectatindex:0]; NSString *v = [L objectatindex:1]; [Adict setobject:v forkey:k]; } return adict;}
iOS opens other apps, and is opened by other apps