Posts tagged with ios5

Adding iOS5 native Twitter support to your cocos2d app

In iOS5, Apple introduced native Twitter integration via the "Tweet Sheet" (aka TWTweetComposeViewController), allowing you to easily implement Twitter in your iOS app without worrying about all the heavy lifting. If you tried implementing Twitter support in the past and found yourself lost in a sea of OAuth source files, trying to handle authentication yourself, and banging your head over what to do with various responses, you'll know how much of a relief it is that this now "just works."

This is great for UIKit, but what if you want to implement the same simple Twitter sharing functionality in your cocos2d game? Luckily, it's nearly as easy!

Continue reading...

iOS5 Notification Center disables Local Notifications by default on your existing apps

If your iOS app uses UILocalNotifications, you (and your users) may be wondering why you haven't been receiving them after updating iOS 5. It seems that due to a bug (or is it undocumented feature?) in iOS 5, Local Notifications now behave a lot more like Push Notifications.

By default, if your app does not register for push notifications, it will not be in the Notification Center and thus unable to send notifications (remote or local). Of course your users can always manually go into Settings -> Notifications and hunt down your app, but not all users will realize this and - as in our case - many may think your app is 'broken' in iOS 5.

Until Apple (hopefully) releases an update to fix this, a workaround is to register your app to receive Remote/Push Notifications (even if you don't use them) so that your app is "in" the Notification Center and able to receive Local Notifications. To do this, in your App Delegate's application didFinishLaunchingWithOptions method, add the following:

  1.  
  2. // Workaround for iOS5 bug. We need to register for remote notifications,
  3. // otherwise all notifications are disabled by default in the Notification Center
  4.  
  5. [[UIApplication sharedApplication]
  6. registerForRemoteNotificationTypes:
  7. UIRemoteNotificationTypeBadge |
  8. UIRemoteNotificationTypeAlert |
  9. UIRemoteNotificationTypeSound];
  10.  

At startup, your app will now prompt the user to receive push notifications and when they accept, join the ranks of other Push Notification apps in the Notification Center.