IOS & WatchOS background communication - swift

I have a IOS application with a companion WatchOS application. I am wondering if there is a way I can communicate with the IOS application in real time while it not running as a foreground application.
The best example I can think of is how your are able to use the Spotify watch app to change songs, like songs or even change the volume of the phone while the phone is locked.
How could I implement something like this for an application that could possibly send data frequently from the watch to the phone while the phone is locked.

Watch apps can launch their companion iOS apps by messaging them:. https://developer.apple.com/documentation/watchconnectivity/wcsession/1615687-sendmessage
That won’t work if the iOS device requires unlock because it’s just booted up.

I just started WatchOS development and needed to send a message to the watch app - if it's available I use sendMessage. If the watch app is backgrounded, I use transferUserInfo. Link to code snippets. I check isReachable and isPaired (on the phone, isPaired does not exist in WatchOS).

Related

Show a notification from watchOS 2 app

It is possible to show a notification from Apple watchOS 2 native app? Although watchOS 2 applications can run directly on the Apple watch device, it still hasn't reference to the UIApplication.SharedApplication, so I can't all the UIApplication.presentLocalNotificationNow() directly from the WatchKit app an it seems that also the WKExtensionDelegate cannot be used to show instant notifications.
The WKExtensionDelegate can respond to local notifications via the didReceiveLocalNotification(_:) method. Your iPhone app will have to schedule the notification. If it is an even that only the watch knows about, you can send a message to the phone app using the WCSession set of APIs.

Something like shared NSUserDefaults and App Groups in watchOS 2?

I am currently updating an app of mine for watchOS 2 and got some trouble with communication between the devices: previously I had been using shared NSUserDefaults to enable both the Watch and the iOS device to read and write several values from one App Group independently.
Now that watchOS 2 apps are running natively on the Watch and the Watch Connectivity Framework replaced previous communication options, this no longer seems applicable. However, from what I read on the reference, implementing the same functionality I had in watchOS 1 with Watch Connectivity is rather cumbersome…
Is there any other option for me to create some sort of container/file/database/whatsoever that I can access and update from both my Watch app and the related iOS app?
With watchOS 2 both the WatchKit App and Extension run natively on Apple Watch, so even if you use shared user defaults or app groups the data you put inside them will be on the watch and so not accessible from the iOS app.
To send data to the watch you can use the WatchConnectivity framework, or use a NSURLSession to download data from a server if that's your case.

How to send msg between iPhone app and WatchKit app?

I am newer one for Apple Watch development.
Can you please provide me about how to communicate from iPhone app to Watch app and from Watch app to iPhone app ?
As I can see, there is a notification controller which is related Apple Push notification. I would like to connect to Watch app directly via Bluetooth or something. For example, As soon as iPhone app sends a MGS to Watch app, the watch app shows this MSG without any delay.
Thank you.
In order to communicate with the iPhone app from your Watch extension you can use openParentApplication(_:reply:) since Beta 2.
For the other way around I have been putting a file into the shared app group folder and monitor it from the Watch extension. If the iPhone app modifies the file the Watch extension will be notified and can act on it.

is it possible phone-calling in ipad?

Recent iPads are having provision to insert sim card in that. So with latest iOS SDK, is it possible to call from my application. I know that in-app call is possible from iPhone. But how about iPad? is any api for that? or any app already in market? any tutorials or links .
thanks
The 3G ipad doesn't support native phone calls. The 3G is just for data transfer. However there's nothing stopping you from creating an app similar to the way Skype and other voice over ip apps work, that allow you to make phone calls from the ipad. Line2 is an example of such an app.
It's not possible. The iPad was not created to make phone calls, and there is no native Phone app (like what the iPhone has).
The SIM card slot is to allow internet use via 3G.

how can i control the Phone call?

I am new to iphone. now i am doing one baby monitoring project. My part is controlling sound like if the baby was crying that automatically call to that baby's mom mobile number.
So here i did all works, but if baby was crying that will call automatically from application to baby's mom mobile number.
But after reach the mobile number the application was end. so how can i rectify this problem. that means if suppose she stop the call it will goes to the application.
Iphone did not allow multitasking before version 4.x of the iOS. This means that when the phone app launches your application is closed. So it will not be possible pre iOS 4.x. For iOS 4.x You can keep your application running but there is still no way to bring your application to the foreground automatically. What you can do (in any version) is present the user with a notification to take you back to your app but the user has to opt in and touch the notification.