Skip to content

Commit d6c2ed1

Browse files
authored
Merge pull request #1192 from OneSignal/user_model/testing
[user model] changes and fixes made during testing (round 1)
2 parents dd3d890 + 6523094 commit d6c2ed1

File tree

64 files changed

+1154
-992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1154
-992
lines changed

OneSignal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Pod::Spec.new do |s|
77
s.author = { "Joseph Kalash" => "[email protected]", "Josh Kasten" => "[email protected]" , "Brad Hesse" => "[email protected]"}
88

99
s.source = { :git => "https://github.com/OneSignal/OneSignal-iOS-SDK.git", :tag => s.version.to_s }
10-
s.platform = :ios, "9.0"
10+
s.platform = :ios, "11.0"
1111
s.requires_arc = true
1212

1313
s.ios.vendored_frameworks = 'iOS_SDK/OneSignalSDK/OneSignal_XCFramework/OneSignalFramework.xcframework'

OneSignalXCFramework.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Pod::Spec.new do |s|
77
s.author = { "Joseph Kalash" => "[email protected]", "Josh Kasten" => "[email protected]" , "Brad Hesse" => "[email protected]"}
88

99
s.source = { :git => "https://github.com/OneSignal/OneSignal-iOS-SDK.git", :tag => s.version.to_s }
10-
s.platform = :ios, '9.0'
10+
s.platform = :ios, '11.0'
1111
s.requires_arc = true
1212

1313
s.ios.vendored_frameworks = 'iOS_SDK/OneSignalSDK/OneSignal_XCFramework/OneSignalFramework.xcframework'

iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#import <UIKit/UIKit.h>
3232
#import <OneSignalFramework/OneSignalFramework.h>
3333

34-
@interface AppDelegate : UIResponder <UIApplicationDelegate, OSPermissionObserver, OSSubscriptionObserver, OSInAppMessageLifecycleHandler>
34+
@interface AppDelegate : UIResponder <UIApplicationDelegate, OSPermissionObserver, OSInAppMessageLifecycleHandler, OSPushSubscriptionObserver>
3535

3636
@property (strong, nonatomic) UIWindow *window;
3737

iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5050
// [FIRApp configure];
5151

5252
NSLog(@"Bundle URL: %@", [[NSBundle mainBundle] bundleURL]);
53-
5453
[OneSignal.Debug setLogLevel:ONE_S_LL_VERBOSE];
5554
[OneSignal.Debug setVisualLevel:ONE_S_LL_NONE];
55+
56+
[OneSignal initialize:[AppDelegate getOneSignalAppId] withLaunchOptions:launchOptions];
57+
5658
_notificationDelegate = [OneSignalNotificationCenterDelegate new];
5759

5860
id openNotificationHandler = ^(OSNotificationOpenedResult *result) {
61+
// TODO: opened handler Not triggered
5962
NSLog(@"OSNotificationOpenedResult: %@", result.action);
6063
#pragma clang diagnostic push
6164
#pragma clang diagnostic ignored "-Wdeprecated"
@@ -80,7 +83,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8083
// OneSignal Init with app id and lauch options
8184
[OneSignal setLaunchURLsInApp:YES];
8285
[OneSignal setProvidesNotificationSettingsView:NO];
83-
[OneSignal initialize:[AppDelegate getOneSignalAppId] withLaunchOptions:launchOptions];
86+
8487

8588
[OneSignal.Notifications requestPermission:^(BOOL accepted) {
8689
NSLog(@"OneSignal Demo App requestPermission: %d", accepted);
@@ -92,13 +95,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
9295
[OneSignal.Notifications setNotificationWillShowInForegroundHandler:notificationReceiverBlock];
9396
[OneSignal.Notifications setNotificationOpenedHandler:openNotificationHandler];
9497

98+
OSPushSubscriptionState* state = [OneSignal.User.pushSubscription addObserver:self];
99+
NSLog(@"OneSignal Demo App push subscription observer added, current state: %@", state);
100+
101+
[OneSignal.Notifications addPermissionObserver:self];
102+
95103
NSLog(@"UNUserNotificationCenter.delegate: %@", UNUserNotificationCenter.currentNotificationCenter.delegate);
96104

97105
return YES;
98106
}
99107

100-
#define ONESIGNAL_APP_ID_DEFAULT @"0ba9731b-33bd-43f4-8b59-61172e27447d"
101-
#define ONESIGNAL_APP_ID_KEY_FOR_TESTING @"ONESIGNAL_APP_ID_KEY_FOR_TESTING"
108+
#define ONESIGNAL_APP_ID_DEFAULT @"1688d8f2-da7f-4815-8ee3-9d13788482c8"
109+
#define ONESIGNAL_APP_ID_KEY_FOR_TESTING @"1688d8f2-da7f-4815-8ee3-9d13788482c8"
102110

103111
+ (NSString*)getOneSignalAppId {
104112
NSString* userDefinedAppId = [[NSUserDefaults standardUserDefaults] objectForKey:ONESIGNAL_APP_ID_KEY_FOR_TESTING];
@@ -118,10 +126,10 @@ - (void) onOSPermissionChanged:(OSPermissionStateChanges*)stateChanges {
118126
NSLog(@"onOSPermissionChanged: %@", stateChanges);
119127
}
120128

121-
- (void) onOSSubscriptionChanged:(OSSubscriptionStateChanges*)stateChanges {
122-
NSLog(@"onOSSubscriptionChanged: %@", stateChanges);
129+
- (void)onOSPushSubscriptionChangedWithStateChanges:(OSPushSubscriptionStateChanges *)stateChanges {
130+
NSLog(@"onOSPushSubscriptionChangedWithStateChanges: %@", stateChanges);
123131
ViewController* mainController = (ViewController*) self.window.rootViewController;
124-
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.isSubscribed;
132+
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.optedIn;
125133
}
126134

127135
#pragma mark OSInAppMessageDelegate

iOS_SDK/OneSignalDevApp/OneSignalDevApp/Base.lproj/Main.storyboard

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<constraint firstAttribute="width" constant="68" id="com-ja-CVD"/>
4444
</constraints>
4545
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
46-
<state key="normal" title="Get Tags"/>
46+
<state key="normal" title="INFO"/>
4747
<connections>
4848
<action selector="getTagsButton:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Pp8-oA-Zrh"/>
4949
</connections>
@@ -298,7 +298,7 @@
298298
<rect key="frame" x="118" y="581" width="136" height="30"/>
299299
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="15"/>
300300
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
301-
<state key="normal" title="Set External User Id"/>
301+
<state key="normal" title="Login to External User Id"/>
302302
<connections>
303303
<action selector="setExternalUserId:" destination="BYZ-38-t0r" eventType="touchUpInside" id="DXf-1K-Lkc"/>
304304
</connections>
@@ -374,11 +374,11 @@
374374
<fontDescription key="fontDescription" type="system" pointSize="14"/>
375375
<textInputTraits key="textInputTraits"/>
376376
</textField>
377-
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OiG-L7-Ot2" userLabel="Remove External User Id">
377+
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" selected="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OiG-L7-Ot2" userLabel="Logout">
378378
<rect key="frame" x="103" y="619" width="168" height="30"/>
379379
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="15"/>
380380
<color key="tintColor" red="1" green="0.1367101157" blue="0.01701983743" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
381-
<state key="normal" title="Remove External User Id"/>
381+
<state key="normal" title="Logout"/>
382382
<connections>
383383
<action selector="removeExternalUserId:" destination="BYZ-38-t0r" eventType="touchUpInside" id="F3N-HQ-tSv"/>
384384
</connections>

iOS_SDK/OneSignalDevApp/OneSignalDevApp/OneSignalDevApp.entitlements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</array>
1212
<key>com.apple.security.application-groups</key>
1313
<array>
14-
<string>group.com.onesignal.example.onesignal</string>
14+
<string>group.com.onesignal.example.staging.onesignal</string>
1515
</array>
1616
</dict>
1717
</plist>

iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,14 @@ - (void)handleMessageAction:(NSString *)actionId {
164164
}
165165

166166
- (IBAction)setExternalUserId:(UIButton *)sender {
167-
NSLog(@"setExternalUserId is no longer supported. Please use login or addAlias.");
167+
NSString* externalUserId = self.externalUserIdTextField.text;
168+
NSLog(@"Dev App: Logging in to external user ID %@", externalUserId);
169+
[OneSignal login:externalUserId];
168170
}
169171

170172
- (IBAction)removeExternalUserId:(UIButton *)sender {
171-
NSLog(@"setExternalUserId is no longer supported. Please use logout or removeAlias.");
173+
NSLog(@"Dev App: Logout called.");
174+
[OneSignal logout];
172175
}
173176

174177
#pragma mark UITextFieldDelegate Methods

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#import <UIKit/UIKit.h>
1010
#import <OneSignalFramework/OneSignalFramework.h>
1111

12-
@interface AppDelegate : UIResponder <UIApplicationDelegate, OSPermissionObserver, OSSubscriptionObserver>
12+
// TODO: Add subscription observer
13+
@interface AppDelegate : UIResponder <UIApplicationDelegate, OSPermissionObserver>
1314

1415
@property (strong, nonatomic) UIWindow *window;
1516

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/AppDelegate.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ - (void) onOSPermissionChanged:(OSPermissionStateChanges*)stateChanges {
116116
NSLog(@"onOSPermissionChanged: %@", stateChanges);
117117
}
118118

119-
- (void) onOSSubscriptionChanged:(OSSubscriptionStateChanges*)stateChanges {
120-
NSLog(@"onOSSubscriptionChanged: %@", stateChanges);
121-
ViewController* mainController = (ViewController*) self.window.rootViewController;
122-
mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.isSubscribed;
123-
}
119+
// TODO: Add push sub observer
120+
//- (void) onOSSubscriptionChanged:(OSSubscriptionStateChanges*)stateChanges {
121+
// NSLog(@"onOSSubscriptionChanged: %@", stateChanges);
122+
// ViewController* mainController = (ViewController*) self.window.rootViewController;
123+
// mainController.subscriptionSegmentedControl.selectedSegmentIndex = (NSInteger) stateChanges.to.isSubscribed;
124+
//}
124125

125126
- (void)applicationWillResignActive:(UIApplication *)application {
126127
}

iOS_SDK/OneSignalDevApp/OneSignalDevAppClip/OneSignalDevAppClip.entitlements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</array>
1212
<key>com.apple.developer.parent-application-identifiers</key>
1313
<array>
14-
<string>$(AppIdentifierPrefix)com.onesignal.example</string>
14+
<string>$(AppIdentifierPrefix)com.onesignal.example.staging</string>
1515
</array>
1616
</dict>
1717
</plist>

0 commit comments

Comments
 (0)