Skip to content

Commit 8193d85

Browse files
committed
merging in 5.0.0 branch
2 parents eb8e2f2 + 61ad43c commit 8193d85

File tree

72 files changed

+1563
-1025
lines changed

Some content is hidden

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

72 files changed

+1563
-1025
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 @"YOUR_APP_ID_HERE"
109+
#define ONESIGNAL_APP_ID_KEY_FOR_TESTING @"YOUR_APP_ID_HERE"
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>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// LiveActivityController.swift
3+
// OneSignalExample
4+
//
5+
// Created by Henry Boswell on 11/9/22.
6+
// Copyright © 2022 OneSignal. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import ActivityKit
11+
import UserNotifications
12+
13+
struct OneSignalWidgetAttributes: ActivityAttributes {
14+
public struct ContentState: Codable, Hashable {
15+
// Dynamic stateful properties about your activity go here!
16+
var message: String
17+
}
18+
19+
// Fixed non-changing properties about your activity go here!
20+
var title: String
21+
}
22+
@objc
23+
class LiveActivityController: NSObject {
24+
// To aid in testing
25+
static var counter = 0
26+
@available(iOS 13.0, *)
27+
@objc
28+
static func createActivity() async -> String? {
29+
if #available(iOS 16.1, *) {
30+
counter += 1;
31+
let attributes = OneSignalWidgetAttributes(title: "#" + String(counter) + " OneSignal Dev App Live Activity")
32+
let contentState = OneSignalWidgetAttributes.ContentState(message: "Update this message through push or with Activity Kit")
33+
do {
34+
let activity = try Activity<OneSignalWidgetAttributes>.request(
35+
attributes: attributes,
36+
contentState: contentState,
37+
pushType: .token)
38+
for await data in activity.pushTokenUpdates {
39+
let myToken = data.map {String(format: "%02x", $0)}.joined()
40+
return myToken
41+
}
42+
} catch (let error) {
43+
print(error.localizedDescription)
44+
return nil
45+
}
46+
}
47+
return nil
48+
}
49+
}

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
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}

0 commit comments

Comments
 (0)