ios - how to transfer text or pdf file with URL Scheme -


i want inter app communication in between 2 appliocation url scheme. have gone through apple documentation,but won't help.

i have make 2 projects, in sender there 1 method in added

{     uiapplication *ourapplication = [uiapplication sharedapplication];      nscharacterset *set = [nscharacterset urlhostallowedcharacterset];     nsstring *urlencodedtext = [@"test" stringbyaddingpercentencodingwithallowedcharacters:set];     nsstring *ourpath = [@"readtext://" stringbyappendingstring:urlencodedtext];     nsurl *oururl = [nsurl urlwithstring:ourpath];     if ([ourapplication canopenurl:oururl]) {         [ourapplication openurl:oururl];     }     else {     uialertcontroller * alert=   [uialertcontroller                                       alertcontrollerwithtitle:@"receiver not found"                                       message:@"the receiver app not installed"                                       preferredstyle:uialertcontrollerstylealert];          [self presentviewcontroller:alert animated:yes completion:nil];         nslog(@"receiver not found");     } } 

and in receiver app,added below code app delegate

- (bool)application:(uiapplication *)application handleopenurl:(nsurl *)url  {      nscharacterset *set = [nscharacterset urlhostallowedcharacterset];     nsstring *text = [[url host] stringbyaddingpercentencodingwithallowedcharacters:set];      uialertcontroller * alert=   [uialertcontroller                                   alertcontrollerwithtitle:@"title"                                   message:text                                   preferredstyle:uialertcontrollerstylealert];      [self.window.rootviewcontroller presentviewcontroller:alert animated:yes completion:nil];      return yes; } 

also add in info.plist , in url types under info.

you add code in .plist file:

<key>cfbundleurltypes</key> <array>     <dict>         <key>cfbundleurlname</key>         <string>$(product_bundle_identifier)</string>         <key>cfbundleurlschemes</key>         <array>             <string>scheme_name</string>         </array>     </dict> </array> 

write code call event:

// use url  [nsurl urlwithstring:@"scheme_name://"]  

only see item1:

i implement code in 1 project today widget working. note: steps replace scheme_name in image.

enter image description here


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -