How to receive scheduled notification (Local Notification) from iphone to apple watch - ios

I would like to know that whether we can receive scheduled local notification from iphone device and we can receive that notification on Apple watch. I also want to update the status in my local database from that notification.
Note:
The app is local, it's not remote and have local database in which we have to update the status of that notification.
Thanks in advance.

Check following table from Apple and
Link

It is not possible at the moment. Unfortunately, the only way to receive notifications on Apple Watch at the moment is to have the iPhone locked.

Related

Any way to know that a local iOS notification was displayed to the user if the user did not interact with it

I am trying to write a notification tracking system for my app. My understanding is that a scheduled local notification is guaranteed to get delivered but that my app won't get a notice that it was delivered unless the user interacts with that notification in some way. Am I missing something? Is there some event or notification sent to the app simply to indicate that the notification appeared?
No, I don't think you have any way of knowing about the "notification not taken."
A Jailbroken device would be a different matter.
There are silent push notifications, and I haven't looked at the new notifications API in iOS 10, so I guess it's possible Apple added a silent local notification for iOS 10...
Actually there are 2 scenarios:
App in background: When a local notification is delivered by the system, app is not notified, only if user interacts with notification view app is awakened.
App in foreground: App is notified when a local notification is delivered by calling didReceiveLocalNotification method.
Local notifications are guaranteed to be delivered only is user allows this (app will ask user to allow to receive local notifications)

Does silent push notification able to awake app which is in not running state in ios?

i want to insert push notification data into sqlite even if my app is in not running state(Close state).
How do i achieve this???
Type of Notification is silent push notification.
Yes you can. Check out Apple's documentation here
If your server sends push notifications to a user’s device when new
content is available for your app, you can ask the system to run your
app in the background so that it can begin downloading the new content
right away.
If the app has killed by a user or it's terminated by OS then your app will not awake.
Check this link iOS Silent Push Notification

Sending push notifications directly to watchOS 2?

On iOS, we can register for push notifications using the registerForRemoteNotifications method on UIApplication.
I want to create a watchOS 2 app that will work even if my watch is not connected to my phone (but is connected to Wi-Fi). I would like to send push notifications from a server to the watch directly. Is there a way to do this?
If so, what are the equivalent of these methods in a watchOS 2 extension?
application.registerForRemoteNotifications
application(:, didRegisterForRemoteNotificationsWithDeviceToken:)
application(:, didFailToRegisterForRemoteNotificationsWithError:)
application(:, didReceiveRemoteNotification:)
If not, what are my other options?
Currently there is no way to directly get notification from server on watch. As mentioned in Notification Essentials for watch
Apple Watch displays local and remote notifications only if the
containing iOS supports them. For information about how to support
local and remote notifications in your iOS app, see Local and Remote
Notification Programming Guide.
This also mentioned that
When one of your app’s local or remote notifications arrives on the
user’s iPhone, iOS decides whether to display that notification on the
iPhone or on the Apple Watch
Now there are some scenrio in this, if your phone is active and notification arrives, it will be received on phone. but if phone is locked and watch is active and then notification arrived it will be displayed on watch.
It is also mentioned in Apple Push Notification Service Doc that
Apple Push Notification service (APNs) is the centerpiece of the
remote notifications feature. It is a robust and highly efficient
service for propagating information to iOS (and, indirectly, watchOS),
tvOS, and OS X devices.

Create Watchkit notification programmatically

I'm looking to push a notification to the Apple Watch at a specific time. I was able to display a static message on the simulator using an apns file, but I'd like to set the data and time of the notification in the controller.
I heard I might not be able to do this on a simulator, but if I got a real phone and watch, how would it work?
So, you want to do something in the watch app extension and based on the results, schedule a UILocalNotification that will be sent to the phone at some point?
You cannot directly schedule a UILocalNotification from the watch because you don't have access to the UIApplication object. See Apple staff comment here. However, using Watch Connectivity, you could send a message from the watch to the phone and have the phone app create and schedule it in the background. The watch will display the notification iff the phone is locked at the trigger time. The watch's notification scene will be invoked in that case.
Assuming you want to send the notification from the phone to the watch: You can use UILocalNotification to send a notification to the watch - but the watch must be locked to receive it. There's also no guarantee when the Watch OS will turn on the watch to run the code that receives your notification, so your notification may arrive minutes or hours after it's sent.

Is it possible to send a local notification to the Apple Watch specifically?

I see this in the Apple Watch Programming Guide:
When one of your app’s local or remote notifications arrives on the
user’s iPhone, iOS decides whether to display that notification on the
iPhone or on the Apple Watch.
Is there a way to make a notification only appear on the watch?
This was not possible until watchOS 3.
watchOS 3 introduces the User Notifications framework, which supports the delivery and handling of local and remote notifications. You can use the classes of this framework to schedule the delivery of local notifications based on specific conditions, such as a date or time or after a time interval, and to receive and handle local and remote notifications when they are delivered to the user’s device.
You can now schedule a local notification on the watch, and the notification is (delivered to and) only handled by the watch. It will not appear on the phone.
For more information, see the WWDC 2016 Introduction to Notifications, and Quick Interaction Techniques for watchOS sessions.
Useful picture from this guide:
Unfortunately no, with watch apps you now need to handle notifications in 3 places. When the app is running, application:didReceiveLocalNotification: is called. When the phone is unlocked the notification is sent to the notification center and you'll need to handle the user selecting it in application:didFinishLaunchingWithOptions:. The watch will automatically handle any notification its containing app gets, displaying the app and the alert's body. If you want a custom notification you'll need to setup a notification category in the containing app and a dynamic notification in the watch. If you're trying to just get information from the app to the watch you can use the app groups dictionary or the openParentApplication:reply: method.
Nope. It's completely controlled by the OS.
Whatever you can do on the watch app, you can check it from this relatively simple documentation:https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/
And I don't think you can do something like what you say. We have to admit that there are a lots limitations in this version of WatchKit.

Resources