Skip to content

Commit 7e7f6f8

Browse files
author
Joseph Kalash
committed
- Added support for a 4th key kOSSettingsKeyInFocusDisplay that adds the ability to customize how notifications should appear when the app is in the foreground.
- Fixed receivedBlock not getting called on iOS10 when the app in foreground and OSInFocusDisplayOption is set to None. - Fixed "no push token" issue for projects with no proper `-ObjC`/`-all_load` flags set by forcing the `UIApplication` category to load regardless of the SDK installation method. - Enum values were renamed for easier auto-fill and to prevent namespace conflicts. - Updated example projects (No need for bridging header / linker flags).
1 parent 6127639 commit 7e7f6f8

File tree

14 files changed

+150
-88
lines changed

14 files changed

+150
-88
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.9"
3+
s.version = "2.1.10"
44
s.summary = "OneSignal push notification library for mobile apps."
55
s.homepage = "https://onesignal.com"
66
s.license = { :type => 'MIT', :file => 'LICENSE' }

OneSignalExample/OneSignalExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@
610610
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../iOS_SDK/Framework\"/**";
611611
INFOPLIST_FILE = "push-notifications/OneSignalExample-Info.plist";
612612
LIBRARY_SEARCH_PATHS = "$(inherited)";
613-
OTHER_LDFLAGS = "-ObjC";
613+
OTHER_LDFLAGS = "";
614614
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
615615
PRODUCT_NAME = OneSignalExample;
616616
PROVISIONING_PROFILE = "";
@@ -633,7 +633,7 @@
633633
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../iOS_SDK/Framework\"/**";
634634
INFOPLIST_FILE = "push-notifications/OneSignalExample-Info.plist";
635635
LIBRARY_SEARCH_PATHS = "$(inherited)";
636-
OTHER_LDFLAGS = "-ObjC";
636+
OTHER_LDFLAGS = "";
637637
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
638638
PRODUCT_NAME = OneSignalExample;
639639
PROVISIONING_PROFILE = "";

OneSignalSwiftExample/OneSignalSwiftExample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
91E4D5171C7521DE00025BA8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
7676
91E4D51A1C7521DE00025BA8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7777
91E4D51C1C7521DE00025BA8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
78-
91E4D5241C7522D700025BA8 /* OneSignalSwiftExample-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OneSignalSwiftExample-Bridging-Header.h"; sourceTree = "<group>"; };
7978
/* End PBXFileReference section */
8079

8180
/* Begin PBXFrameworksBuildPhase section */
@@ -168,7 +167,6 @@
168167
91E4D5171C7521DE00025BA8 /* Assets.xcassets */,
169168
91E4D5191C7521DE00025BA8 /* LaunchScreen.storyboard */,
170169
91E4D51C1C7521DE00025BA8 /* Info.plist */,
171-
91E4D5241C7522D700025BA8 /* OneSignalSwiftExample-Bridging-Header.h */,
172170
);
173171
path = OneSignalSwiftExample;
174172
sourceTree = "<group>";
@@ -549,7 +547,7 @@
549547
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
550548
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
551549
PRODUCT_NAME = "$(TARGET_NAME)";
552-
SWIFT_OBJC_BRIDGING_HEADER = "OneSignalSwiftExample/OneSignalSwiftExample-Bridging-Header.h";
550+
SWIFT_OBJC_BRIDGING_HEADER = "";
553551
SWIFT_VERSION = 3.0;
554552
};
555553
name = Debug;
@@ -565,7 +563,7 @@
565563
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
566564
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
567565
PRODUCT_NAME = "$(TARGET_NAME)";
568-
SWIFT_OBJC_BRIDGING_HEADER = "OneSignalSwiftExample/OneSignalSwiftExample-Bridging-Header.h";
566+
SWIFT_OBJC_BRIDGING_HEADER = "";
569567
SWIFT_VERSION = 3.0;
570568
};
571569
name = Release;

OneSignalSwiftExample/OneSignalSwiftExample/AppDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
import UIKit
29+
import OneSignal
2930

3031
@UIApplicationMain
3132
class AppDelegate: UIResponder, UIApplicationDelegate {

OneSignalSwiftExample/OneSignalSwiftExample/OneSignalSwiftExample-Bridging-Header.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

OneSignalSwiftExample/OneSignalSwiftExample/ViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import OneSignal
1011

1112
class ViewController: UIViewController {
1213

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,31 @@
6161
#endif
6262

6363
/* The action type associated to an OSNotificationAction object */
64-
typedef enum : NSUInteger {
65-
Opened,
66-
ActionTaken
67-
} OSNotificationActionType;
64+
typedef NS_ENUM(NSUInteger, OSNotificationActionType) {
65+
OSNotificationActionTypeOpened,
66+
OSNotificationActionTypeActionTaken
67+
} ;
6868

6969
/* The way a notification was displayed to the user */
70-
typedef enum : NSUInteger {
71-
/*iOS native notification display*/
72-
Notification,
73-
70+
typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
71+
/*Notification is silent, or app is in focus but InAppAlertNotifications are disabled*/
72+
OSNotificationDisplayTypeNone,
73+
7474
/*Default UIAlertView display*/
75-
InAppAlert,
75+
OSNotificationDisplayTypeInAppAlert,
7676

77-
/*Notification is silent, or app is in focus but InAppAlertNotifications are disabled*/
78-
None
79-
} OSNotificationDisplayType;
77+
/*iOS native notification display*/
78+
OSNotificationDisplayTypeNotification
79+
} ;
80+
81+
82+
83+
/* iOS 10+
84+
Used as value type for `kOSSettingsKeyInFocusDisplayOption`
85+
for setting the display option of a notification received while the app was in focus
86+
*/
87+
typedef OSNotificationDisplayType OSInFocusDisplayOption;
88+
8089

8190
@interface OSNotificationAction : NSObject
8291

@@ -191,6 +200,12 @@ extern NSString * const kOSSettingsKeyInAppAlerts;
191200
/*Enable In-App display of Launch URLs*/
192201
extern NSString * const kOSSettingsKeyInAppLaunchURL;
193202

203+
/* iOS10+ -
204+
Set notificaion's in-focus display option.
205+
Value must be an OSNotificationDisplayType enum
206+
*/
207+
extern NSString * const kOSSettingsKeyInFocusDisplayOption;
208+
194209
/**
195210
OneSignal provides a high level interface to interact with OneSignal's push service.
196211
OneSignal is a singleton for applications which use a globally available client to share configuration settings.
570 KB
Binary file not shown.

iOS_SDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
3E464ED51D88ED0C00DCF7E9 /* NSObject+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD84001D4936F9008F135D /* NSObject+Extras.m */; };
2525
3E464ED61D88ED0C00DCF7E9 /* NSString+Hash.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD84031D49416A008F135D /* NSString+Hash.m */; };
2626
3E464ED71D88ED1F00DCF7E9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E6B2BA19D9CAF300D0C601 /* UIKit.framework */; };
27-
3E464ED81D88ED2400DCF7E9 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E08E2701D49A5C8002176DE /* SystemConfiguration.framework */; };
28-
3E464EDA1D88EE6A00DCF7E9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E464ED91D88EE6A00DCF7E9 /* Foundation.framework */; };
2927
3E464EDB1D88EF0B00DCF7E9 /* UIApplication+Swizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E3414611D42F1A200EB2546 /* UIApplication+Swizzling.m */; };
3028
3E464EDC1D88EF3C00DCF7E9 /* OneSignalWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E14F6331D3DB0E7008BF4E2 /* OneSignalWebView.m */; };
3129
3E464EDD1D88F48C00DCF7E9 /* OneSignalHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD83FD1D49364E008F135D /* OneSignalHelper.m */; };
@@ -34,6 +32,7 @@
3432
3E464EE11D88F4B500DCF7E9 /* OneSignalMobileProvision.m in Sources */ = {isa = PBXBuildFile; fileRef = 37D6E07D1B1EAE6500EC3624 /* OneSignalMobileProvision.m */; };
3533
3E464EE21D88F4B900DCF7E9 /* OneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 37E277031ACB940000D49C8D /* OneSignal.m */; };
3634
3E464EE31D88F4BF00DCF7E9 /* OneSignalTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EB26DBE1D5121D000E51BD4 /* OneSignalTracker.m */; };
35+
3E66F5821D90A2C600E45A01 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E08E2701D49A5C8002176DE /* SystemConfiguration.framework */; };
3736
3E84C6231D4AE53500ED8557 /* NSObject+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD84001D4936F9008F135D /* NSObject+Extras.m */; };
3837
3E8998B61D37268F0066A9ED /* OneSignal.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 37E277041ACB940000D49C8D /* OneSignal.h */; };
3938
3EB26DBF1D5121D000E51BD4 /* OneSignalTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EB26DBE1D5121D000E51BD4 /* OneSignalTracker.m */; };
@@ -106,8 +105,7 @@
106105
isa = PBXFrameworksBuildPhase;
107106
buildActionMask = 2147483647;
108107
files = (
109-
3E464EDA1D88EE6A00DCF7E9 /* Foundation.framework in Frameworks */,
110-
3E464ED81D88ED2400DCF7E9 /* SystemConfiguration.framework in Frameworks */,
108+
3E66F5821D90A2C600E45A01 /* SystemConfiguration.framework in Frameworks */,
111109
3E464ED71D88ED1F00DCF7E9 /* UIKit.framework in Frameworks */,
112110
);
113111
runOnlyForDeploymentPostprocessing = 0;
@@ -529,7 +527,7 @@
529527
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
530528
ONLY_ACTIVE_ARCH = NO;
531529
OTHER_CFLAGS = "-fembed-bitcode";
532-
OTHER_LDFLAGS = "-all_load";
530+
OTHER_LDFLAGS = "";
533531
PRODUCT_NAME = OneSignal;
534532
SKIP_INSTALL = YES;
535533
};
@@ -542,7 +540,7 @@
542540
GCC_PREFIX_HEADER = "OneSignal/OneSignal-Prefix.pch";
543541
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
544542
OTHER_CFLAGS = "-fembed-bitcode";
545-
OTHER_LDFLAGS = "-all_load";
543+
OTHER_LDFLAGS = "";
546544
PRODUCT_NAME = OneSignal;
547545
SKIP_INSTALL = YES;
548546
};
@@ -568,6 +566,7 @@
568566
MTL_ENABLE_DEBUG_INFO = YES;
569567
ONLY_ACTIVE_ARCH = YES;
570568
OTHER_CFLAGS = "-fembed-bitcode";
569+
OTHER_LDFLAGS = "";
571570
PRODUCT_BUNDLE_IDENTIFIER = "com.onesignal.OneSignal-Dynamic";
572571
PRODUCT_NAME = OneSignal;
573572
SKIP_INSTALL = YES;
@@ -598,6 +597,7 @@
598597
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
599598
MTL_ENABLE_DEBUG_INFO = NO;
600599
OTHER_CFLAGS = "-fembed-bitcode";
600+
OTHER_LDFLAGS = "";
601601
PRODUCT_BUNDLE_IDENTIFIER = "com.onesignal.OneSignal-Dynamic";
602602
PRODUCT_NAME = OneSignal;
603603
SKIP_INSTALL = YES;

iOS_SDK/OneSignal/OneSignal.h

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,31 @@
6161
#endif
6262

6363
/* The action type associated to an OSNotificationAction object */
64-
typedef enum : NSUInteger {
65-
Opened,
66-
ActionTaken
67-
} OSNotificationActionType;
64+
typedef NS_ENUM(NSUInteger, OSNotificationActionType) {
65+
OSNotificationActionTypeOpened,
66+
OSNotificationActionTypeActionTaken
67+
} ;
6868

6969
/* The way a notification was displayed to the user */
70-
typedef enum : NSUInteger {
71-
/*iOS native notification display*/
72-
Notification,
73-
70+
typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
71+
/*Notification is silent, or app is in focus but InAppAlertNotifications are disabled*/
72+
OSNotificationDisplayTypeNone,
73+
7474
/*Default UIAlertView display*/
75-
InAppAlert,
75+
OSNotificationDisplayTypeInAppAlert,
7676

77-
/*Notification is silent, or app is in focus but InAppAlertNotifications are disabled*/
78-
None
79-
} OSNotificationDisplayType;
77+
/*iOS native notification display*/
78+
OSNotificationDisplayTypeNotification
79+
} ;
80+
81+
82+
83+
/* iOS 10+
84+
Used as value type for `kOSSettingsKeyInFocusDisplayOption`
85+
for setting the display option of a notification received while the app was in focus
86+
*/
87+
typedef OSNotificationDisplayType OSInFocusDisplayOption;
88+
8089

8190
@interface OSNotificationAction : NSObject
8291

@@ -191,6 +200,12 @@ extern NSString * const kOSSettingsKeyInAppAlerts;
191200
/*Enable In-App display of Launch URLs*/
192201
extern NSString * const kOSSettingsKeyInAppLaunchURL;
193202

203+
/* iOS10+ -
204+
Set notificaion's in-focus display option.
205+
Value must be an OSNotificationDisplayType enum
206+
*/
207+
extern NSString * const kOSSettingsKeyInFocusDisplayOption;
208+
194209
/**
195210
OneSignal provides a high level interface to interact with OneSignal's push service.
196211
OneSignal is a singleton for applications which use a globally available client to share configuration settings.

0 commit comments

Comments
 (0)