Tag Archives: rubymotion

iOS 8 Push Notifications in RubyMotion

iOS 8 changed the way apps register for push notifications. In order for your app to register for push notifications successfully on both iOS 7 and 8 you’ll need to check the version number and register differently.

if !Device.simulator?
  if Device.ios_version.start_with? "8"
    settings = UIUserNotificationSettings.settingsForTypes((UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound |           UIRemoteNotificationTypeAlert), categories:nil)
    UIApplication.sharedApplication.registerUserNotificationSettings(settings)
    UIApplication.sharedApplication.registerForRemoteNotifications
  else
    UIApplication.sharedApplication.registerForRemoteNotificationTypes(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)
  end
end

RubyMotion Launch Image

There is no way to specify a launch image directly in the Rakefile with the standard RubyMotion config options. The launch image is considered an advanced configuration option and can be set using the advanced plist settings technique which is detailed here: Advanced Info.plist Settings.

Basically you just use the app’s info_plist property to set any keys or values necessary in the Info.plist file that RubyMotion does not expose configuration options for.

I added this to my Rakefile to make it happen:

app.info_plist['UILaunchImageFile'] = 'launch'

Here, ‘launch’ is the base name for the images. This means that the filenames would look like this:

launch.png : 320 x 480px
launch@2x.png: 640 x 960px
launch-568h@2x.png : 640 x 1136px