Connecting apple watch to parse notifications? - ios

I want my parse notifications to show on the apple watch, and simply open the app on the iPhone when the okay button is tapped. How would I go about doing this? Thanks!

According apple:
"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."
So, you can't ensure that notification will be received on the watch.
Also, in case the notification is received on the applewatch, it is not possible to open the iPhone by pressing a Button (or anything). It does not exist such a method for that. The only way to open the app is manually.

Related

How to simulate a local/push notification in iOS simulator?

WatchKit allows us to simulate notifications with an .apns file.
How can I do the same thing in an iOS app? (Preferably in the simulator.)
The reason I ask is that I want to have the debugger active when the app is initially launched via a notification (i.e. I want to see what happens in the application:didFinishLaunchingWithOptions: method). If I start a new debugging session it will call application:didFinishLaunchingWithOptions: immediately, and then I can never test that code path when I tap on the notification.
There isn't any way to simulate a notification in the simulator. You can debug to a real device and send a sandbox push notification to hit that function in Xcode.

Local notifications while iphone is unlocked only

Is there a way to send local notifications only when the iphone is unlocked? I don't want to send local notifications while the iphone is locked. Thanks
If you’re scheduling them in advance, no; if you’re using -presentLocalNotificationNow: from an app that’s running in the background, you should be able to use the UIApplication protectedDataAvailable property to check whether the device is unlocked at the time. You can also ask your users to turn off the “Show on Lock Screen” switch in the notification settings for your app.

How iOS Notifications Work, if App notification setting is set OFF then ON?

Is it possible to see old notifications in my iOS device, if I set the app notification settings from OFF state to ON state?
Say for instance, I have set my App notification settings as "OFF" yesterday where the APP admin has sent custom notification message. Today I noticed that the App Settings are in OFF state. So I changed the settings to ON. Will I get that custom notification now?
No it's not possible,Once you de-authorise any app to send Push Notifications then your device isn't able to receive the notification from that particular app,So you can't find the old notifications.

How to trigger notifications using WatchKit

In the WatchKit developer guide, there are instructions on how to render custom notifications and it also says:
Apps are not required to do anything to support notifications. The system provides a default notification interface that displays the alert message from the notification. However, apps can customize the notification interface and include custom graphics, content, and branding.
I can get local notifications to trigger banner alerts on the phone, but they don't happen on the WatchKit app. I have tried debugging using all of the targets:
iOS app
Watch app
Watch Glance
Watch custom notification
Even while the phone app is in the background, none seem to trigger when the local notification is received. I have also tried this by simulating a remote notification being received in the background.
I'm hoping I don't have to call the watchKit's controller local/remote notification handlers directly.
I'm hoping I don't have to call the watchKit's controller local/remote notification handlers directly.
No, you don't.
The answer is XCode doesn't support debugging Apple Watch and iPhone simultaneously for now. That's why you can't push a notification from iPhone simulator to Watch simulator, only payload test by *.apns files is supported for now.
Its explained in Notification Essentials that
iOS decides whether to display that notification on the iPhone or on Apple Watch .
So I dont think(as of now) there is anything that can be done from the app to trigger Notifications specifically in the watch.
Edit: It looks like theres a bug in 8.2 beta.
WatchKit Known Issues
When viewing a notification in iOS simulator, clicking on the notification icon or body does not launch the corresponding Watch app
Release notes
In order to test watch notifications, you must first create a new build scheme.
Duplicate your watch app scheme, and in the "Run" section, choose your custom notification as the executable.
Now you can run the notification scheme.
Inside the extensions group in your project, under Supporting Files is a file called PushNotificationPayload.json.
You can edit the payload file to try different notifications and categories.
Source
I only had two targets when I created the projects:
[app name]
[app name] Watch App
Editing the Watch App scheme allows me to select another executable -- notably there's the Glance and Notification options there, and they work for me. Just select it, close, and run. I haven't tried duplicating the targets/schemes so I don't have to edit them, but I don't think that would be an issue.
Edit: Actually, the SDK tells you to edit the scheme too.

How to reprompt for IOS app for push notifications

My app uses push notifications. If the user says no to push notifications when they install the app, but then a few days later decides they want push notifications, how do I program that option in the app in a settings? Do I just call registerForRemoteNotificationTypes (actually AppDelegate does this every time the app is stated) ?
You can't. The user has to go into settings on the device and allow notifications there.
You can see if notifications are enabled with the enabledRemoteNotificationTypes property of UIApplication and prompt the user to go to settings, but this would be incredibly spammy. You'd be better off having some text in a settings screen.

Resources