Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

id notificationReceiverBlock = ^(OSNotification *notification) {
NSLog(@"Received Notification - %@", notification.payload.notificationID);

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:11];
};

[OneSignal initWithLaunchOptions:launchOptions
Expand Down
10 changes: 4 additions & 6 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/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>OneSignal_require_privacy_consent</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down Expand Up @@ -31,10 +29,8 @@
<string>Test Location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Test Location2</string>
<key>OneSignal_app_groups_key</key>
<string> group.com.onesignal.example.testgroup </string>
<key>OneSignal_disable_badge_clearing</key>
<true/>
<key>OneSignal_require_privacy_consent</key>
<false/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
Expand All @@ -47,6 +43,8 @@
<array>
<string>armv7</string>
</array>
<key>OneSignal_disable_badge_clearing</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
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>OneSignal_app_groups_key</key>
<string>group.com.onesignal.example.testgroup</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
13 changes: 12 additions & 1 deletion iOS_SDK/OneSignalSDK/Source/OneSignalExtensionBadgeHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ + (NSInteger)currentCachedBadgeValue {
return [(NSNumber *)[userDefaults objectForKey:ONESIGNAL_BADGE_KEY] integerValue];
}

//gets the NSBundle of the primary application - NOT the app extension
//this way we can determine the bundle ID for the host (primary) application.
+ (NSString *)primaryBundleIdentifier {
NSBundle *bundle = [NSBundle mainBundle];
if ([[bundle.bundleURL pathExtension] isEqualToString:@"appex"])
bundle = [NSBundle bundleWithURL:[[bundle.bundleURL URLByDeletingLastPathComponent] URLByDeletingLastPathComponent]];

return [bundle bundleIdentifier];

}

+ (void)updateCachedBadgeValue:(NSInteger)value {
//since badge logic can be executed in an extension, we need to use app groups to get
//a shared NSUserDefaults from the app group suite name
Expand All @@ -77,7 +88,7 @@ + (NSString *)appGroupName {
var appGroupName = (NSString *)[[NSBundle mainBundle] objectForInfoDictionaryKey:ONESIGNAL_APP_GROUP_NAME_KEY];

if (!appGroupName)
appGroupName = [NSString stringWithFormat:@"group.%@.%@", [[NSBundle mainBundle] bundleIdentifier], @"onesignal"];
appGroupName = [NSString stringWithFormat:@"group.%@.%@", OneSignalExtensionBadgeHandler.primaryBundleIdentifier, @"onesignal"];

return [appGroupName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
Expand Down