How do i start a watch kit notification? - swift

Im creating a app and i would like know how to start a notification to apple watch from apple watch and from iphone to apple watch
I thought local and remote notification could anyone help me????

Do you mean notifications to test your app? Or notifications in general? For notifications in general, I think (but I'm not 100% sure tough) that right now you can't choose where a notification appears, and that both local and remote notifications received by the containing iPhone app will be displayed by Apple Watch (and you can customise their behaviour and style).
To test notifications on Apple Watch, edit the scheme of your watch app and choose to display a notification from a .apns file.

Notification (local or remote) will be appeared on your Apple Watch device as it is paired with your iPhone, iPhone is locked and watches are on your wrist.
To handle incoming notifications on your WatchKit App you should create a Notification Interface Controller in your WatchKit App target's storyboard.
First it will be as a static interface. Also you can add the dynamic one and create a subclass of WKUserNotificationInterfaceController in WatchKit Extension. Link this subclass with the storyboard dynamic notification controller in Identity Inspector pane.
After all you should implement next methods in your subclass:
- (void)didReceiveLocalNotification:withCompletion:
- (void)didReceiveRemoteNotification:withCompletion:
Hope it helps!

in completion with x401om awnser :
you can't fire a local notification from apple watch to iPhone. in fact you can't choose to :
Senario 1 : The user have the phone non-locked, the notification (local or push) is always delivered to the iphone, and not the watch
Senario 2 : The iphone is locked and watch is on you're watch, and you have done some local or push notification (for local at an date and time) then the apple watch recieve the notification.

Related

Programmatically notification on apple watch. (WatchOS 3)

How I can programmatically make the notification appear only on the apple watch and only when the event occurs. I searched for a long time on the Internet and in the documentation but did not find the answer
There is no way for you to decide whether the notification appears on the Watch or on the Phone, the system handles this automatically and you cannot change this behaviour.
The notification only appears on the Watch if all of the below requirements are met:
The connected iPhone's screen is locked
The watch is worn by the user in case WristDetection is turned on
Do not disturb mode is turned off on the Watch

How to use Apple watch PushNotificationPayload.apns

I'm trying to understand the usage of PushNotificationPayload.apns
From what I understand, I can only specify this file if running through the simulator. If that's the case, how am I supposed to receive remote notifications? Since when does the simulator support remote notifications? And even if it does, how do I get the device token from it?
Thanks
PushNotificationPayload.apns is indeed usable in the simulator only. It is actually useful because the Simulator does not support push notification.
It is simply a file containing a Push Notification payload that can be used to simulate receiving a push notification on the Simulator.
You can tell the simulator this payload should be used in your tests by editing your WatchKit App scheme, setting the Watch Interface to Dynamic or Static Notification. Then you’ll be able to specify which payload to use for the notification view.

Apple Watch and iphone communication

I am implementing apple watch app with in my existing app.I need to full fill these task between both iphone and watch
1) sending data from watch to iphone Done (by using openParentApplication).
2) getting call back also done (using openParentApplication call back method)
3) I need to get apple watch notify when user click on a button on iphone app .I have implemented reverse functionality using openParentApplication.
I stuck how to update apple watch UI after user click on any button or any particular task happen on iphone app.
Please let me know is there any way to perform passing event and data from iphone to apple watch
Please use this link https://github.com/mutualmobile/MMWormhole for communication between iphone and watchKit.
You should checkout the new WCSessionDelegate is watchOS 2.0. It can be implemented on both the Apple Watch and contains multiple methods for sending data back and forth between the two devices. Detailed information can be found in the WWDC video Introducing Watch Connectivity

Watchkit - How to schedule notification only for Apple Watch?

I have created an App with Apple Watch extension.
I would like to know if it's possible to schedule a notification that only appears on the Apple Watch. And conversely, can we schedule a notification to only appear on the iPhone?
This is a great question, but unfortunately it is not possible at this time. Apple is trying to be very pragmatic about how they direct notifications. If you iPhone is unlocked, they assume you are looking at it and will route notifications there. If you iPhone is locked, then all notifications will be routed to your Apple Watch. They want to avoid duplicated notifications in both locations at all costs.
Currently there is no ability to force route remote or local notifications directly to the Watch only. If you feel strongly about this feature, then I would suggest you file an enhancement radar with the Apple Bug Reporting System.
In the official Apple documentation they said that:
Apple Watch takes full advantage of the existing interactive
notification support on iOS. If your iOS app supports notifications,
Apple Watch displays those notifications at appropriate times. 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. For notifications sent to Apple Watch, the
system lets the the user know subtly that a notification is available.
If the user chooses to view the notification, the system displays an
abbreviated version of the notification first, followed by a more
detailed version. The user can dismiss the detailed notification,
launch your WatchKit app, or act on the notification by tapping an
available action button.
https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html
So I think you can tell to iOS the behavior of your notifications (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. For notifications sent to Apple Watch, the
system lets the the user know subtly that a notification is available.)

iPhone/iPod Touch sync notifications

I know that it's possible to add an observer for notifications with the com.apple.iTunes.playerInfo identifier, but this only seems to include events for music related events.
I also know I can find out when iTunes closes by adding an observer for NSWorkspaceDidTerminateApplicationNotification.
But is there an NSNotification for the start/finish of iPhone syncing with iTunes?
Just to be clear, my question is about what happens on a Mac not on an iPhone.