Skip to content

Commit

Permalink
Merge pull request #4 from contexthub/dev
Browse files Browse the repository at this point in the history
Fix crashing bug when launching app on pre-iOS 8
  • Loading branch information
jeffkibuule committed Sep 16, 2014
2 parents 9f98343 + e69fed9 commit c71cf79
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
22 changes: 10 additions & 12 deletions NotifyMe/NMAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ @implementation NMAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Register with ContextHub
#ifdef DEBUG
// The debug flag is automatically set by the compiler, indicating which push gateway server your device will use
// Xcode deployed builds use the sandbox/development server
Expand All @@ -30,18 +29,17 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Register the app id of the application you created on https://app.contexthub.com
[ContextHub registerWithAppId:@"YOUR-PUSH-APP-ID-HERE"];


// Register for remote notifications
#ifdef __IPHONE_8_0
// iOS 8 and above
UIUserNotificationType notificationTypes = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#else
// iOS 7 and below
UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
#endif
if ([UIUserNotificationSettings class]) {
// iOS 8 and above
UIUserNotificationType notificationTypes = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
// iOS 7 and below
UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
}

// Clear badge
application.applicationIconBadgeNumber = 0;
Expand Down
8 changes: 4 additions & 4 deletions NotifyMe/NotifyMe-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationAlwaysUsageDescription</key>
<string>NotifyMe needs to use background location updates for location changes to work correctly.</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand All @@ -19,13 +17,15 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>139</string>
<string>140</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocationAlwaysUsageDescription</key>
<string>NotifyMe needs to use background location updates for location changes to work correctly.</string>
<key>NSMainNibFile~ipad</key>
<string>Main</string>
<key>UIBackgroundModes</key>
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ Below shows the basics of how the CCHPush class is used to send and receive push
// Register the app id of the application you created on https://app.contexthub.com
[ContextHub registerWithAppId:@"YOUR-APP-ID-HERE"];

// Register for remote notifications
#ifdef __IPHONE_8_0
// iOS 8 and above
UIUserNotificationType notificationTypes = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#else
// iOS 7 and below
UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
#endif
// Register for remote notifications
if ([UIUserNotificationSettings class]) {
// iOS 8 and above
UIUserNotificationType notificationTypes = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
// iOS 7 and below
UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
}

return YES;
}
Expand Down
6 changes: 5 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Notify Me (Push) Sample App Release Notes
---

## v1.0.1 (Build 139) - September 17, 2014
## v1.0.2 (Build 140) - September 16, 2014
- Fix crashing bug when launching app on pre-iOS 8 device
- Update README

## v1.0.1 (Build 139) - September 16, 2014
- Update to ContextHub v1.3.1 framework
- Update compatibility for iOS 8
- Update README
Expand Down

0 comments on commit c71cf79

Please sign in to comment.