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

Hack24 2.0 out now!

So, finally I got some time to update Hack24, my first ever MMO for iOS.  2.0 is not as big upgraded as I hoped but added some more fun to the game.

  • You can now customise the colour and building type
  • You can now message online players
  • NPC have been introduced to add more fun
  • Bug fixes
  • Game balancing
  • iOS8 fixes

Next, I plan to improve performance, the game keeps getting new users, and so development will continue

You can get it free from iTunes

Developing for the Pebble Steel

I don’t generally wear a watch but for Christmas my wife got me a Pebble Steel smart watch which was exactly what I wanted 🙂  I wanted this over an Android Wear device because it works with iOS as well as Android, plus it has a battery life of more than a day!

The watch works seamlessly with my iPhone, and everything is so easy to use, access etc.  I find it funny the Pebble Steel works so well with iOS but my Google Glass does not (yes there is an iOS app for Google Glass, getting all of your notifications to appear on the Glass seems impossible.)

Developing for the Pebble is done online in their Cloud Editor, you can develop using Javascript or C.  As a iOS developer I went for C and was really impressed by how easy it was to develop in a browser and then deploy to the watch with a single click of a button!  The tutorials are pretty easy to follow and understand.  I did have an issue when I switched to using Javascript (3rd tutorial) where you have to define constants via the IDE settings area.   However that could of been user error 🙂

I think they have done a real good job from start to finish with the Pebble.  If you fancy starting development, check out Developer.getpebble.com

10897778_10152879471120033_1425203151548046278_n

 

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

iBeacon

A bit more fun than the normal day at work, I was asked to investigate iBeacons.  We had been sent 4 3rd party iBeacons to try out which had been setup with different Major and Minor settings and transmitting frequency (seconds).

To be honest, I did not know where to start, however a nice tutorial on Raywenderlich.com covered everything I needed to know to complete the tutorial.

iBeacons Tutorial