File tree Expand file tree Collapse file tree 4 files changed +16
-11
lines changed
OneSignalNotificationServiceExtension Expand file tree Collapse file tree 4 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -59,8 +59,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5959
6060 id notificationReceiverBlock = ^(OSNotification *notification) {
6161 NSLog (@" Received Notification - %@ " , notification.payload .notificationID );
62-
63- [[UIApplication sharedApplication ] setApplicationIconBadgeNumber: 11 ];
6462 };
6563
6664 [OneSignal initWithLaunchOptions: launchOptions
Original file line number Diff line number Diff line change 22<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33<plist version =" 1.0" >
44<dict >
5- <key >OneSignal_require_privacy_consent </key >
6- <true />
75 <key >CFBundleDevelopmentRegion </key >
86 <string >en </string >
97 <key >CFBundleExecutable </key >
3129 <string >Test Location </string >
3230 <key >NSLocationWhenInUseUsageDescription </key >
3331 <string >Test Location2 </string >
34- <key >OneSignal_app_groups_key </key >
35- <string > group.com.onesignal.example.testgroup </string >
36- <key >OneSignal_disable_badge_clearing </key >
37- <true />
32+ <key >OneSignal_require_privacy_consent </key >
33+ <false />
3834 <key >UIBackgroundModes </key >
3935 <array >
4036 <string >remote-notification </string >
4743 <array >
4844 <string >armv7 </string >
4945 </array >
46+ <key >OneSignal_disable_badge_clearing </key >
47+ <false />
5048 <key >UISupportedInterfaceOrientations </key >
5149 <array >
5250 <string >UIInterfaceOrientationPortrait </string >
Original file line number Diff line number Diff line change 22<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33<plist version =" 1.0" >
44<dict >
5- <key >OneSignal_app_groups_key </key >
6- <string >group.com.onesignal.example.testgroup </string >
75 <key >CFBundleDevelopmentRegion </key >
86 <string >en </string >
97 <key >CFBundleDisplayName </key >
Original file line number Diff line number Diff line change @@ -63,6 +63,17 @@ + (NSInteger)currentCachedBadgeValue {
6363 return [(NSNumber *)[userDefaults objectForKey: ONESIGNAL_BADGE_KEY] integerValue ];
6464}
6565
66+ // gets the NSBundle of the primary application - NOT the app extension
67+ // this way we can determine the bundle ID for the host (primary) application.
68+ + (NSString *)primaryBundleIdentifier {
69+ NSBundle *bundle = [NSBundle mainBundle ];
70+ if ([[bundle.bundleURL pathExtension ] isEqualToString: @" appex" ])
71+ bundle = [NSBundle bundleWithURL: [[bundle.bundleURL URLByDeletingLastPathComponent ] URLByDeletingLastPathComponent ]];
72+
73+ return [bundle bundleIdentifier ];
74+
75+ }
76+
6677+ (void )updateCachedBadgeValue : (NSInteger )value {
6778 // since badge logic can be executed in an extension, we need to use app groups to get
6879 // a shared NSUserDefaults from the app group suite name
@@ -77,7 +88,7 @@ + (NSString *)appGroupName {
7788 var appGroupName = (NSString *)[[NSBundle mainBundle ] objectForInfoDictionaryKey: ONESIGNAL_APP_GROUP_NAME_KEY];
7889
7990 if (!appGroupName)
80- appGroupName = [NSString stringWithFormat: @" group.%@ .%@ " , [[ NSBundle mainBundle ] bundleIdentifier ] , @" onesignal" ];
91+ appGroupName = [NSString stringWithFormat: @" group.%@ .%@ " , OneSignalExtensionBadgeHandler.primaryBundleIdentifier , @" onesignal" ];
8192
8293 return [appGroupName stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet ]];
8394}
You can’t perform that action at this time.
0 commit comments