Skip to content

Commit a6e5b32

Browse files
committed
Fixed issue where action buttons sets would not always updated
* Instead of deleting existing dynamic categories created by the SDK for action button sets we are creating duplicates. - This was causing iOS to use the pre-existing category old category instead of the new one.
1 parent 5da5e40 commit a6e5b32

File tree

7 files changed

+276
-3
lines changed

7 files changed

+276
-3
lines changed

iOS_SDK/OneSignalDevApp/OneSignalDevApp.xcodeproj/project.pbxproj

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,37 @@
1515
9112E8951E724C320022A1CB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9112E8931E724C320022A1CB /* LaunchScreen.storyboard */; };
1616
9112E8A51E724ECC0022A1CB /* libOneSignal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9112E8A31E724DCB0022A1CB /* libOneSignal.a */; };
1717
9112E8A71E724EE00022A1CB /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9112E8A61E724EE00022A1CB /* SystemConfiguration.framework */; };
18+
9150E7761E73BEDD00C5D46A /* NotificationService.m in Sources */ = {isa = PBXBuildFile; fileRef = 9150E7751E73BEDD00C5D46A /* NotificationService.m */; };
19+
9150E77A1E73BEDD00C5D46A /* OneSignalNotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9150E7721E73BEDC00C5D46A /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
20+
91A7F0AE1E73C1780055AA50 /* libOneSignal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9112E8A31E724DCB0022A1CB /* libOneSignal.a */; };
21+
91A7F0AF1E73C1A20055AA50 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9112E8A61E724EE00022A1CB /* SystemConfiguration.framework */; };
22+
91A7F0B01E73C1A80055AA50 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9150E7821E73BFB600C5D46A /* UIKit.framework */; };
1823
/* End PBXBuildFile section */
1924

25+
/* Begin PBXContainerItemProxy section */
26+
9150E7781E73BEDD00C5D46A /* PBXContainerItemProxy */ = {
27+
isa = PBXContainerItemProxy;
28+
containerPortal = 9112E87A1E724C320022A1CB /* Project object */;
29+
proxyType = 1;
30+
remoteGlobalIDString = 9150E7711E73BEDC00C5D46A;
31+
remoteInfo = OneSignalNotificationServiceExtension;
32+
};
33+
/* End PBXContainerItemProxy section */
34+
35+
/* Begin PBXCopyFilesBuildPhase section */
36+
9150E77E1E73BEDD00C5D46A /* Embed App Extensions */ = {
37+
isa = PBXCopyFilesBuildPhase;
38+
buildActionMask = 2147483647;
39+
dstPath = "";
40+
dstSubfolderSpec = 13;
41+
files = (
42+
9150E77A1E73BEDD00C5D46A /* OneSignalNotificationServiceExtension.appex in Embed App Extensions */,
43+
);
44+
name = "Embed App Extensions";
45+
runOnlyForDeploymentPostprocessing = 0;
46+
};
47+
/* End PBXCopyFilesBuildPhase section */
48+
2049
/* Begin PBXFileReference section */
2150
9112E8821E724C320022A1CB /* OneSignalDevApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OneSignalDevApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
2251
9112E8861E724C320022A1CB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -31,6 +60,12 @@
3160
9112E8A31E724DCB0022A1CB /* libOneSignal.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libOneSignal.a; path = "../../../../../Library/Developer/Xcode/DerivedData/OneSignalSDK-gokrmgmincuokwdzxidzbpukovwj/Build/Products/Debug-iphoneos/libOneSignal.a"; sourceTree = "<group>"; };
3261
9112E8A61E724EE00022A1CB /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
3362
9112E8A81E72506C0022A1CB /* OneSignalDevApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OneSignalDevApp.entitlements; sourceTree = "<group>"; };
63+
9150E7721E73BEDC00C5D46A /* OneSignalNotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OneSignalNotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
64+
9150E7741E73BEDD00C5D46A /* NotificationService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationService.h; sourceTree = "<group>"; };
65+
9150E7751E73BEDD00C5D46A /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = "<group>"; };
66+
9150E7771E73BEDD00C5D46A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
67+
9150E77F1E73BF5B00C5D46A /* OneSignal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OneSignal.framework; path = "../../../../../Library/Developer/Xcode/DerivedData/OneSignalSDK-gokrmgmincuokwdzxidzbpukovwj/Build/Products/Debug-iphoneos/OneSignal.framework"; sourceTree = "<group>"; };
68+
9150E7821E73BFB600C5D46A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
3469
/* End PBXFileReference section */
3570

3671
/* Begin PBXFrameworksBuildPhase section */
@@ -43,13 +78,24 @@
4378
);
4479
runOnlyForDeploymentPostprocessing = 0;
4580
};
81+
9150E76F1E73BEDC00C5D46A /* Frameworks */ = {
82+
isa = PBXFrameworksBuildPhase;
83+
buildActionMask = 2147483647;
84+
files = (
85+
91A7F0B01E73C1A80055AA50 /* UIKit.framework in Frameworks */,
86+
91A7F0AF1E73C1A20055AA50 /* SystemConfiguration.framework in Frameworks */,
87+
91A7F0AE1E73C1780055AA50 /* libOneSignal.a in Frameworks */,
88+
);
89+
runOnlyForDeploymentPostprocessing = 0;
90+
};
4691
/* End PBXFrameworksBuildPhase section */
4792

4893
/* Begin PBXGroup section */
4994
9112E8791E724C320022A1CB = {
5095
isa = PBXGroup;
5196
children = (
5297
9112E8841E724C320022A1CB /* OneSignalDevApp */,
98+
9150E7731E73BEDD00C5D46A /* OneSignalNotificationServiceExtension */,
5399
9112E8831E724C320022A1CB /* Products */,
54100
9112E8A21E724DCA0022A1CB /* Frameworks */,
55101
);
@@ -59,6 +105,7 @@
59105
isa = PBXGroup;
60106
children = (
61107
9112E8821E724C320022A1CB /* OneSignalDevApp.app */,
108+
9150E7721E73BEDC00C5D46A /* OneSignalNotificationServiceExtension.appex */,
62109
);
63110
name = Products;
64111
sourceTree = "<group>";
@@ -91,12 +138,24 @@
91138
9112E8A21E724DCA0022A1CB /* Frameworks */ = {
92139
isa = PBXGroup;
93140
children = (
141+
9150E7821E73BFB600C5D46A /* UIKit.framework */,
142+
9150E77F1E73BF5B00C5D46A /* OneSignal.framework */,
94143
9112E8A61E724EE00022A1CB /* SystemConfiguration.framework */,
95144
9112E8A31E724DCB0022A1CB /* libOneSignal.a */,
96145
);
97146
name = Frameworks;
98147
sourceTree = "<group>";
99148
};
149+
9150E7731E73BEDD00C5D46A /* OneSignalNotificationServiceExtension */ = {
150+
isa = PBXGroup;
151+
children = (
152+
9150E7741E73BEDD00C5D46A /* NotificationService.h */,
153+
9150E7751E73BEDD00C5D46A /* NotificationService.m */,
154+
9150E7771E73BEDD00C5D46A /* Info.plist */,
155+
);
156+
path = OneSignalNotificationServiceExtension;
157+
sourceTree = "<group>";
158+
};
100159
/* End PBXGroup section */
101160

102161
/* Begin PBXNativeTarget section */
@@ -107,16 +166,35 @@
107166
9112E87E1E724C320022A1CB /* Sources */,
108167
9112E87F1E724C320022A1CB /* Frameworks */,
109168
9112E8801E724C320022A1CB /* Resources */,
169+
9150E77E1E73BEDD00C5D46A /* Embed App Extensions */,
110170
);
111171
buildRules = (
112172
);
113173
dependencies = (
174+
9150E7791E73BEDD00C5D46A /* PBXTargetDependency */,
114175
);
115176
name = OneSignalDevApp;
116177
productName = OneSignalDevApp;
117178
productReference = 9112E8821E724C320022A1CB /* OneSignalDevApp.app */;
118179
productType = "com.apple.product-type.application";
119180
};
181+
9150E7711E73BEDC00C5D46A /* OneSignalNotificationServiceExtension */ = {
182+
isa = PBXNativeTarget;
183+
buildConfigurationList = 9150E77D1E73BEDD00C5D46A /* Build configuration list for PBXNativeTarget "OneSignalNotificationServiceExtension" */;
184+
buildPhases = (
185+
9150E76E1E73BEDC00C5D46A /* Sources */,
186+
9150E76F1E73BEDC00C5D46A /* Frameworks */,
187+
9150E7701E73BEDC00C5D46A /* Resources */,
188+
);
189+
buildRules = (
190+
);
191+
dependencies = (
192+
);
193+
name = OneSignalNotificationServiceExtension;
194+
productName = OneSignalNotificationServiceExtension;
195+
productReference = 9150E7721E73BEDC00C5D46A /* OneSignalNotificationServiceExtension.appex */;
196+
productType = "com.apple.product-type.app-extension";
197+
};
120198
/* End PBXNativeTarget section */
121199

122200
/* Begin PBXProject section */
@@ -139,6 +217,11 @@
139217
};
140218
};
141219
};
220+
9150E7711E73BEDC00C5D46A = {
221+
CreatedOnToolsVersion = 8.2.1;
222+
DevelopmentTeam = 99SW8E36CT;
223+
ProvisioningStyle = Automatic;
224+
};
142225
};
143226
};
144227
buildConfigurationList = 9112E87D1E724C320022A1CB /* Build configuration list for PBXProject "OneSignalDevApp" */;
@@ -155,6 +238,7 @@
155238
projectRoot = "";
156239
targets = (
157240
9112E8811E724C320022A1CB /* OneSignalDevApp */,
241+
9150E7711E73BEDC00C5D46A /* OneSignalNotificationServiceExtension */,
158242
);
159243
};
160244
/* End PBXProject section */
@@ -170,6 +254,13 @@
170254
);
171255
runOnlyForDeploymentPostprocessing = 0;
172256
};
257+
9150E7701E73BEDC00C5D46A /* Resources */ = {
258+
isa = PBXResourcesBuildPhase;
259+
buildActionMask = 2147483647;
260+
files = (
261+
);
262+
runOnlyForDeploymentPostprocessing = 0;
263+
};
173264
/* End PBXResourcesBuildPhase section */
174265

175266
/* Begin PBXSourcesBuildPhase section */
@@ -183,8 +274,24 @@
183274
);
184275
runOnlyForDeploymentPostprocessing = 0;
185276
};
277+
9150E76E1E73BEDC00C5D46A /* Sources */ = {
278+
isa = PBXSourcesBuildPhase;
279+
buildActionMask = 2147483647;
280+
files = (
281+
9150E7761E73BEDD00C5D46A /* NotificationService.m in Sources */,
282+
);
283+
runOnlyForDeploymentPostprocessing = 0;
284+
};
186285
/* End PBXSourcesBuildPhase section */
187286

287+
/* Begin PBXTargetDependency section */
288+
9150E7791E73BEDD00C5D46A /* PBXTargetDependency */ = {
289+
isa = PBXTargetDependency;
290+
target = 9150E7711E73BEDC00C5D46A /* OneSignalNotificationServiceExtension */;
291+
targetProxy = 9150E7781E73BEDD00C5D46A /* PBXContainerItemProxy */;
292+
};
293+
/* End PBXTargetDependency section */
294+
188295
/* Begin PBXVariantGroup section */
189296
9112E88E1E724C320022A1CB /* Main.storyboard */ = {
190297
isa = PBXVariantGroup;
@@ -321,6 +428,30 @@
321428
};
322429
name = Release;
323430
};
431+
9150E77B1E73BEDD00C5D46A /* Debug */ = {
432+
isa = XCBuildConfiguration;
433+
buildSettings = {
434+
DEVELOPMENT_TEAM = 99SW8E36CT;
435+
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
436+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
437+
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.OneSignalNotificationServiceExtension;
438+
PRODUCT_NAME = "$(TARGET_NAME)";
439+
SKIP_INSTALL = YES;
440+
};
441+
name = Debug;
442+
};
443+
9150E77C1E73BEDD00C5D46A /* Release */ = {
444+
isa = XCBuildConfiguration;
445+
buildSettings = {
446+
DEVELOPMENT_TEAM = 99SW8E36CT;
447+
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
448+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
449+
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.OneSignalNotificationServiceExtension;
450+
PRODUCT_NAME = "$(TARGET_NAME)";
451+
SKIP_INSTALL = YES;
452+
};
453+
name = Release;
454+
};
324455
/* End XCBuildConfiguration section */
325456

326457
/* Begin XCConfigurationList section */
@@ -342,6 +473,15 @@
342473
defaultConfigurationIsVisible = 0;
343474
defaultConfigurationName = Release;
344475
};
476+
9150E77D1E73BEDD00C5D46A /* Build configuration list for PBXNativeTarget "OneSignalNotificationServiceExtension" */ = {
477+
isa = XCConfigurationList;
478+
buildConfigurations = (
479+
9150E77B1E73BEDD00C5D46A /* Debug */,
480+
9150E77C1E73BEDD00C5D46A /* Release */,
481+
);
482+
defaultConfigurationIsVisible = 0;
483+
defaultConfigurationName = Release;
484+
};
345485
/* End XCConfigurationList section */
346486
};
347487
rootObject = 9112E87A1E724C320022A1CB /* Project object */;

iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,13 @@ - (void)applicationDidBecomeActive:(UIApplication *)application {
6969
- (void)applicationWillTerminate:(UIApplication *)application {
7070
}
7171

72+
// Remote
73+
- (void)application:(UIApplication *)application
74+
didReceiveRemoteNotification:(NSDictionary *)userInfo
75+
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
76+
77+
NSLog(@"application:didReceiveRemoteNotification:fetchCompletionHandler: %@", userInfo);
78+
completionHandler(nil);
79+
}
7280

7381
@end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>OneSignalNotificationServiceExtension</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>XPC!</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>NSExtension</key>
24+
<dict>
25+
<key>NSExtensionPointIdentifier</key>
26+
<string>com.apple.usernotifications.service</string>
27+
<key>NSExtensionPrincipalClass</key>
28+
<string>NotificationService</string>
29+
</dict>
30+
</dict>
31+
</plist>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// NotificationService.h
3+
// OneSignalNotificationServiceExtension
4+
//
5+
// Created by Kasten on 3/10/17.
6+
// Copyright © 2017 OneSignal. All rights reserved.
7+
//
8+
9+
#import <UserNotifications/UserNotifications.h>
10+
11+
@interface NotificationService : UNNotificationServiceExtension
12+
13+
@end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#import <OneSignal/OneSignal.h>
2+
3+
#import "NotificationService.h"
4+
5+
@interface NotificationService ()
6+
7+
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
8+
@property (nonatomic, strong) UNNotificationRequest *recievedRequest;
9+
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
10+
11+
@end
12+
13+
@implementation NotificationService
14+
15+
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
16+
self.recievedRequest = request;
17+
self.contentHandler = contentHandler;
18+
self.bestAttemptContent = [request.content mutableCopy];
19+
20+
self.bestAttemptContent.body = @"test [modified]";
21+
22+
[OneSignal didReceiveNotificatioExtensionnRequest:self.recievedRequest withMutableNotificationContent:self.bestAttemptContent];
23+
24+
self.contentHandler(self.bestAttemptContent);
25+
}
26+
27+
- (void)serviceExtensionTimeWillExpire {
28+
// Called just before the extension will be terminated by the system.
29+
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
30+
31+
[OneSignal serviceExtensionTimeWillExpireRequest:self.recievedRequest withMutableNotificationContent:self.bestAttemptContent];
32+
33+
self.contentHandler(self.bestAttemptContent);
34+
}
35+
36+
@end

iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,16 @@ + (void)addActionButtons:(NSArray*)buttonsPayloadList toNotificationContent:(id)
698698

699699
id category = [NSClassFromString(@"UNNotificationCategory") categoryWithIdentifier:@"__dynamic__" actions:actionArray intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
700700

701-
if (allCategories)
702-
[allCategories addObject:category];
701+
if (allCategories) {
702+
NSMutableSet* newCategorySet = [[NSMutableSet alloc] init];
703+
for(id existingCategory in allCategories) {
704+
if (![[existingCategory identifier] isEqualToString:@"__dynamic__"])
705+
[newCategorySet addObject:existingCategory];
706+
}
707+
708+
[newCategorySet addObject:category];
709+
allCategories = newCategorySet;
710+
}
703711
else
704712
allCategories = [[NSMutableSet alloc] initWithArray:@[category]];
705713

0 commit comments

Comments
 (0)