简体   繁体   中英

Objective c access another ios app

I have two apps written with Objective C. I have an IOS 8 jailbroken device. Can I get information from the view of another application?

Can I access self.view of the other app? I want to send a clicks command (touch up inside) to button in my other applications? Is it possible?

I have, ios 8, jailbreak device, xcode 6.3. I'm sorry for my bad english.

no need for jailbrake.

here is something really quick you can try to open and click button in 2nd app.

Use URL schemes to open app from another app.

in the 2nd app in plist in URL types\\item\\URL Schemes\\item0 add string say my2ndapp

to open 2nd app from your 1st app use:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"my2ndapp://somedata"]];

so now url: my2ndapp://somestring - will open your 2nd app and run method in its appdelegate:

(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
  //do something with url if you need to, you can use it to tell yuor 2nd app do different things
openedFromURL=YES;//set bool flag, add this BOOL var in .h of appdelegate
return YES;
}

then in the same appdelegate in method

-(void)applicationDidBecomeActive:(UIApplication*)application{
if(!openedFromURL){return;}
//run method from viewcontroller you want, import it in .m and add it in .h of your appdelegate
MyViewController * myvc = [[MyViewController alloc]init];
[myvc myMethodHere];
openedFromURL=NO;//drop flag
}

you can go to your particular view or viewcontroller and run the method that is associated with your button touch up inside event

Similarly, you can make 2nd app interact with 1st one too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM