Skip to content

Commit 147a3ac

Browse files
author
Joseph Kalash
committed
- iOS 10 fixes:
- In-app alerts will no longer show up alongside native notifications when InAppAlerts are enabled. - Changed the way the OneSignal SDK extracts attachments from the notification payload. - Added a mutableContent property to the OSNotificationPayload for iOS 10. - Remote silent notifications will no longer show an alert in an app that is in focus when InAppAlerts are enabled. - Dismiss the in-app webview when coming back to the app after receiving a deep linked URL and kOSSettingsInAppLaunchURL is true.
1 parent b4516cc commit 147a3ac

File tree

13 files changed

+181
-122
lines changed

13 files changed

+181
-122
lines changed

OneSignal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OneSignal"
3-
s.version = "2.1.0"
3+
s.version = "2.1.1"
44
s.summary = "OneSignal push notification library for mobile apps."
55
s.homepage = "https://onesignal.com"
66
s.license = { :type => 'MIT', :file => 'LICENSE' }

OneSignalExample/push-notifications/AppDelegate.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
3737

3838
[OneSignal initWithLaunchOptions:launchOptions appId:@"b2f7f966-d8cc-11e4-bed1-df8f05be55ba" handleNotificationReceived:^(OSNotification *notification) {
3939
NSLog(@"Received Notification - %@", notification.payload.notificationID);
40-
} handleNotificationAction:^(OSNotificationResult *result) {
40+
} handleNotificationAction:^(OSNotificationOpenedResult *result) {
4141

4242
// This block gets called when the user reacts to a notification received
4343
OSNotificationPayload* payload = result.notification.payload;
@@ -50,8 +50,6 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
5050
if(payload.title)
5151
messageTitle = payload.title;
5252

53-
NSDictionary* additionalData = payload.additionalData;
54-
5553
if (result.action.actionID)
5654
fullMessage = [fullMessage stringByAppendingString:[NSString stringWithFormat:@"\nPressed ButtonId:%@", result.action.actionID]];
5755
}

OneSignalSwiftExample/OneSignalSwiftExample.xcodeproj/project.pbxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
TargetAttributes = {
107107
91E4D50C1C7521DE00025BA8 = {
108108
CreatedOnToolsVersion = 7.2;
109+
DevelopmentTeam = 99SW8E36CT;
109110
SystemCapabilities = {
110111
com.apple.BackgroundModes = {
111112
enabled = 1;
@@ -264,25 +265,29 @@
264265
isa = XCBuildConfiguration;
265266
buildSettings = {
266267
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
268+
DEVELOPMENT_TEAM = 99SW8E36CT;
267269
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../iOS_SDK/Framework\"";
268270
INFOPLIST_FILE = OneSignalSwiftExample/Info.plist;
269271
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
270272
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
271273
PRODUCT_NAME = "$(TARGET_NAME)";
272274
SWIFT_OBJC_BRIDGING_HEADER = "OneSignalSwiftExample/OneSignalSwiftExample-Bridging-Header.h";
275+
SWIFT_VERSION = "";
273276
};
274277
name = Debug;
275278
};
276279
91E4D5211C7521DE00025BA8 /* Release */ = {
277280
isa = XCBuildConfiguration;
278281
buildSettings = {
279282
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
283+
DEVELOPMENT_TEAM = 99SW8E36CT;
280284
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../iOS_SDK/Framework\"";
281285
INFOPLIST_FILE = OneSignalSwiftExample/Info.plist;
282286
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
283287
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
284288
PRODUCT_NAME = "$(TARGET_NAME)";
285289
SWIFT_OBJC_BRIDGING_HEADER = "OneSignalSwiftExample/OneSignalSwiftExample-Bridging-Header.h";
290+
SWIFT_VERSION = "";
286291
};
287292
name = Release;
288293
};

iOS_SDK/Framework/OneSignal.framework/Versions/A/Headers/OneSignal.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ typedef enum : NSUInteger {
144144
requires remote-notification within UIBackgroundModes array of the Info.plist */
145145
@property(readonly, getter=isSilentNotification)BOOL silentNotification;
146146

147+
/* iOS 10+: Indicates wether or not the received notification has mutableContent : 1 assigned to its payload
148+
Used for UNNotificationServiceExtension to launch extension.
149+
*/
150+
#if XC8_AVAILABLE
151+
@property(readonly, getter=hasMutableContent)BOOL mutableContent;
152+
#endif
147153

148154
/* Convert object into an NSString that can be convertible into a custom Dictionary / JSON Object */
149155
- (NSString*)stringify;
@@ -241,7 +247,6 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
241247
+ (void)IdsAvailable:(OSIdsAvailableBlock)idsAvailableBlock;
242248

243249
// - Alerting
244-
// + (void)enableInAppAlertNotification:(BOOL)enable;
245250
+ (void)setSubscription:(BOOL)enable;
246251

247252
// - Posting Notification
-162 KB
Binary file not shown.

iOS_SDK/Framework/OneSignal.framework/Versions/B/Headers/OneSignal.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ typedef enum : NSUInteger {
144144
requires remote-notification within UIBackgroundModes array of the Info.plist */
145145
@property(readonly, getter=isSilentNotification)BOOL silentNotification;
146146

147+
/* iOS 10+: Indicates wether or not the received notification has mutableContent : 1 assigned to its payload
148+
Used for UNNotificationServiceExtension to launch extension.
149+
*/
150+
#if XC8_AVAILABLE
151+
@property(readonly, getter=hasMutableContent)BOOL mutableContent;
152+
#endif
147153

148154
/* Convert object into an NSString that can be convertible into a custom Dictionary / JSON Object */
149155
- (NSString*)stringify;
@@ -241,7 +247,6 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
241247
+ (void)IdsAvailable:(OSIdsAvailableBlock)idsAvailableBlock;
242248

243249
// - Alerting
244-
// + (void)enableInAppAlertNotification:(BOOL)enable;
245250
+ (void)setSubscription:(BOOL)enable;
246251

247252
// - Posting Notification
254 KB
Binary file not shown.

iOS_SDK/OneSignal/OneSignal.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ typedef enum : NSUInteger {
144144
requires remote-notification within UIBackgroundModes array of the Info.plist */
145145
@property(readonly, getter=isSilentNotification)BOOL silentNotification;
146146

147+
/* iOS 10+: Indicates wether or not the received notification has mutableContent : 1 assigned to its payload
148+
Used for UNNotificationServiceExtension to launch extension.
149+
*/
150+
#if XC8_AVAILABLE
151+
@property(readonly, getter=hasMutableContent)BOOL mutableContent;
152+
#endif
147153

148154
/* Convert object into an NSString that can be convertible into a custom Dictionary / JSON Object */
149155
- (NSString*)stringify;
@@ -241,7 +247,6 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
241247
+ (void)IdsAvailable:(OSIdsAvailableBlock)idsAvailableBlock;
242248

243249
// - Alerting
244-
// + (void)enableInAppAlertNotification:(BOOL)enable;
245250
+ (void)setSubscription:(BOOL)enable;
246251

247252
// - Posting Notification

iOS_SDK/OneSignal/OneSignal.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
@implementation OneSignal
7373

74-
NSString* const ONESIGNAL_VERSION = @"020100";
74+
NSString* const ONESIGNAL_VERSION = @"020101";
7575
static NSString* mSDKType = @"native";
7676
static BOOL coldStartFromTapOnNotification = NO;
7777
static BOOL registeredWithApple = NO; //Has attempted to register for push notifications with Apple.
@@ -205,8 +205,10 @@ + (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId
205205
trackIAPPurchase = [[OneSignalTrackIAP alloc] init];
206206

207207
if (NSClassFromString(@"UNUserNotificationCenter")) {
208+
#if XC8_AVAILABLE
208209
[OneSignalHelper registerAsUNNotificationCenterDelegate];
209210
[OneSignalHelper clearCachedMedia];
211+
#endif
210212
}
211213

212214
return self;
@@ -263,8 +265,10 @@ void onesignal_Log(ONE_S_LOG_LEVEL logLevel, NSString* message) {
263265
// "registerForRemoteNotifications*" calls didRegisterForRemoteNotificationsWithDeviceToken
264266
// in the implementation UIApplication(OneSignalPush) below after contacting Apple's server.
265267
+ (void)registerForPushNotifications {
266-
268+
269+
#if XC8_AVAILABLE
267270
[OneSignalHelper requestAuthorization];
271+
#endif
268272

269273
// For iOS 8 devices
270274
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
@@ -761,7 +765,8 @@ + (void)notificationOpened:(NSDictionary*)messageDict isActive:(BOOL)isActive {
761765

762766
[OneSignalHelper lastMessageReceived:messageDict];
763767

764-
if (inAppAlert) {
768+
//Make sure it is not a silent one do display, if inAppAlerts are enabled
769+
if (inAppAlert && ![OneSignalHelper isRemoteSilentNotification:messageDict]) {
765770

766771
NSArray<NSString*>* titleAndBody = [OneSignalHelper getPushTitleBody:messageDict];
767772
id oneSignalAlertViewDelegate = [[OneSignalAlertViewDelegate alloc] initWithMessageDict:messageDict];
@@ -950,13 +955,8 @@ + (void) remoteSilentNotification:(UIApplication*)application UserInfo:(NSDictio
950955
// If 'm' present then the notification has action buttons attached to it.
951956
NSDictionary* data = nil;
952957

953-
if (userInfo[@"os_data"])
954-
data = userInfo[@"os_data"][@"buttons"];
955-
else if (userInfo[@"m"])
956-
data = userInfo;
957-
958-
// - TEMP until server sends special field for attachments
959-
else if (userInfo[@"custom"][@"at"])
958+
// Check for buttons or attachments
959+
if (userInfo[@"os_data"][@"buttons"] || userInfo[@"at"] || userInfo[@"o"])
960960
data = userInfo;
961961

962962
//If buttons -> Data is buttons

iOS_SDK/OneSignal/OneSignalHelper.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@
2626
*/
2727

2828
#import "OneSignal.h"
29+
#import "OneSignalWebView.h"
2930

3031
#pragma clang diagnostic push
3132
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
3233

3334
@interface OneSignalHelper : NSObject
3435

3536
// - Web
37+
+ (OneSignalWebView*)webVC;
3638
+ (void) displayWebView:(NSURL*)url;
3739

3840
// - Notification Opened
@@ -44,15 +46,18 @@
4446
+ (void)handleNotificationAction:(OSNotificationActionType)actionType actionID:(NSString*)actionID displayType:(OSNotificationDisplayType)displayType;
4547

4648
// - iOS 10
49+
+ (BOOL)isiOS10Plus;
50+
#if XC8_AVAILABLE
51+
+ (void)registerAsUNNotificationCenterDelegate;
4752
+ (void) requestAuthorization;
4853
+ (void)conformsToUNProtocol;
49-
+ (void)registerAsUNNotificationCenterDelegate;
5054
+ (void)clearCachedMedia;
55+
+ (id)prepareUNNotificationRequest:(NSDictionary *)data :(NSDictionary *)userInfo;
56+
#endif
5157

5258
// - Notifications
5359
+ (BOOL) isCapableOfGettingNotificationTypes;
5460
+ (UILocalNotification*)prepareUILocalNotification:(NSDictionary*)data :(NSDictionary*)userInfo;
55-
+ (id)prepareUNNotificationRequest:(NSDictionary *)data :(NSDictionary *)userInfo;
5661
+ (BOOL)verifyURL:(NSString *)urlString;
5762
+ (BOOL) isRemoteSilentNotification:(NSDictionary*)msg;
5863

0 commit comments

Comments
 (0)