简体   繁体   中英

Is there inter-app communication when apps start in iOS?

I am relatively new to iOS app development and I'm just trying to figure out some things that, to me, are more abstract. How do apps know when other apps start? The closest example I can think of to what I'm trying to ask is when music is playing in the background and you open another app that has sound and the music stops. Is that the new app taking authority or is there inter app communication? If there is communication how does that communication work? Like is it a message that could be accessed or what?

Sorry if that didn't make much sense, I tried to elaborate the best I could. I couldn't find anything on this on apple's developer website. Thanks in advance!

There is no inter-app communication. Each app is living in its own world, and as far as your app is concerned, it's the only app on the phone. The way communication happens is that an app talks to the system, and the system talks to your app. The way the system sends messages to your app is usually in the delegate of the framework you're working with. In your example, opening your app to play audio will send a message to the system, and the system will tell the other app to stop audio playback. That other app has no idea it was your app that initiated the stop. Another example is the AppDelegate . The app delegate will send your app messages such as application:didFinishLaunchingWithOptions: , which in this method is where you do custom initialization of the app or applicationWillResignActive: which is normally sent when the user presses the home button or receives a phone call, so here you might want to save your game, etc.

In fact the iOS system is quite complicated, much to complicated to be explained in detail here so I highly suggest reading the Apple Developer Documentation , some of it can be a little dry, but they do their best to be coherent with even absolute beginners.

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