Apple Watch : Sending notifications to the watch from the iPhone

The normal way to communicate between the AppleWatch and the iPhone is via AppGroups to share data (shared Prefs, CoreData etc) or by calling the method openParentApplication from the watch and using the delegate method handleWatchKitExtensionRequest.

What would be very nice is if you could notify the watch from the iPhone that something happened, something like a postNotification.  Sadly postNotificaitons do not work, but Darwin ones do!

WatchKit code

– (void)registerTestNotification {

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MY_METHOD) name:@”com.burfdevelopment.test” object:nil];

CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge const void *)(self), didReceivedDarwinNotification, CFSTR(“UPDATE_WATCH”), NULL, CFNotificationSuspensionBehaviorDrop);


static void didReceivedDarwinNotification() {

[[NSNotificationCenter defaultCenter] postNotificationName:@”com.burfdevelopment.test” object:nil];


iPhone code to fire off notification

CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR(UPDATE_WATCH), (__bridge const void *)(self), nil, TRUE);

What have I been up to?

So, as you may or may not know, I changed jobs in March.  This was a pretty big thing for me as I have not changed companies for over 13 years!  My new job is at the O2 Labs as their senior iOS developer (woop woop!).

The lab is tasked with looking in to new tech, create prototypes of useful discoveries and then showing the business how they can use it (their is probably a more official better way to say it).   Generally people are not limited by skillset, so I can look at Android stuff, or robotics or anything that could be useful within reason.

It’s odd changing from a small company to a huge one, but so far its awesome (excluding travelling, damn you M3)!

I have been spending quite a bit of my time researching the new iOS8 api’s which has been fun.  It’s nice just focusing on the new stuff for once.

I have also managed to bring LEGO Mindstorms in to the Lab (well they technically had the old version)


iOS8 Widgets

Quick post, today I was asked to look in to making a simple iOS8 widget that displayed some contacts with status updates, A Widget is a kind of iOS8 extension that is part of your main app but a separate target.  The widget needed to be displayed under the Today notification center.

The first guide I followed showed that Apple had done a really good job on making this super simple!

iOS8 : Creating a Today Widget

Then I needed to share simple data between my parent app and the widget

Sharing NSUserDefaults between your app and a Today Extension on iOS8

The last bit was to make it clickable so that it took you to the main app

iOS8 Day by Day : Today Extension