Watchkit - How to schedule notification only for Apple Watch? - swift

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.)

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 do i start a watch kit notification?

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.

Can I use local notifications for newsstand app subscriptions?

I have a newsstand app that will offer a free subscription that updates daily.
I would like to use push notifications to download the issues in the background.
At first I was considering use UrbanAirship to manage the list of scribers and send out push notifications every day at the same time. Of course this is costly.
Instead would Apple allow me to send local notifications to the app each day at the scheduled time and then the app could go and download the issue in the background, thus avoiding the need for a server to send push notifications or manage a list of scribers or worry about security and certificates etc.
I am not sure about Apple's guideline for this. But I strongly recommend to not try out something like that.
In case your app is not running (not in background) the local notification will not start the download automatically. The Newsstand push notification include the content-available property (with a value of 1) in the JSON payload. Due to this iOS launch your application in background (if not in background) and you can add your content in Newsstand queue for download in background. Once download is complete iOS will close your application. There is no notification alert or any other thing comes which require user to take any action. I think this you cannot achieve through Local Notification.
Other challenges
- How do you make sure the new content is always available when local notification is received .
- How do you figure out what content to download.
Also check out my answer to this question.

Sending notifications from Mac to iPhone/ iPad/ iPod touch

I currently sell a Mac-only productivity tool that uses visual and audio notifications to remind the user of certain events taking place.
I've started planning the iPhone and iPad versions of that Mac program and would like to be able to provide notification services from the Mac to the iPhone, e.g. instead of the Mac playing an audio cue, the iPhone could vibrate, etc.
I have so far done very little iPhone development and I'm not really sure how the various push notification services work. Is this easy enough to do? or is a "challenge".
A few more potentially relevant pieces of information:
there will be a Dropbox-based sync between the iPhone and the Mac versions, so there is also the possibility of "sharing" a file that would prompt some action
it might be acceptable as a first step to not have "background" notifications and require that the iPhone client is running
What authentication issues should I expect to deal with?
You'll need to implement APNs (Apple Push Notification Service) in both your app and your server.
To clarify a few things:
You'll need a server doing those transferring messages job between the user's Mac/PC and their iDevices.
Your server will decide when to push what kind of notification to which user's device.
After that, your server sends a message to Apple's APNs server, which will push that message on your behalf.
It's absolutely OK that your app can be in the background or even closed when the APNs message arrives at the user's device. The user will be guided by the OS to open your app.
If the user has explicitly disabled your app's APNs function in her/his device, or, if the user cancels the APNs alert when it arrives, your app won't be launched if it originally stays in the background or if it hasn't been open yet.
The user will be asked to enable (as you put it, authenticate) your app's APNs function by the OS in her or his device when your app is launched for the first time.
It's not a challenging task for an experienced iOS developer or an experienced PHP developer, since Apple's documents and APIs are pretty straightforward. However, configuration on the server side can be a little tricky.
I believe Stack Overflow already has tons of information on how to enable APNs in iOS apps. All you need to do is be specific in your question and do the search work beforehand.
Hope that helps.

How to show alerts from the application when it is not running?

I have an application in which I have to show the alerts for user specied reminders,
I am able to show these reminders when my application is running but my problem is
i have to show thsese reminders to the user when my application is not running?
is it possible to show the alerts or remindsers when the application is running?
what i obsered in iphone native applications(messages, emails) it whill show no of unread or new messages at the top right tip of the icon on the desktop and it will keep on updates these count.
Can I impplement these king of alerts to my applications? if yes how? it not is there any other to show the alerts when application is not running?
Have a look at Push Notifications. Otherwise this it is not possible.
You'll note that the applications that do this were all written by Apple. As of V3.x of the iPhone, no third party applications can run in the background.
The official way to support this kind of functionality is to use Push Notifications. This requires a server-side component. Push notifications allow you to update the "unread count" or display messages exactly as you describe.
Above both answers are right.
Actually, you can never ever display alerts when application is terminated.
Remember that "iPhone" doesn't allow any background processing.
The alerts that you see are push notifications - which are sent from apple server to iphone.
Basically you need to study about push notifications.
Push notifications are sent from server to iPhone only when it is registered.
( application registers for push notifications - which you can see in settings ).