Skip to content

Commit 09037aa

Browse files
committed
Migration to OneSignal 5.0
1 parent 9554c63 commit 09037aa

File tree

4 files changed

+27
-54
lines changed

4 files changed

+27
-54
lines changed

OPass.xcodeproj/project.pbxproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
D30D9CC228B3F68C00C1E489 /* Modifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30D9CBD28B3F68C00C1E489 /* Modifiers.swift */; };
2626
D30D9CC328B3F68C00C1E489 /* SlideOverCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30D9CBE28B3F68C00C1E489 /* SlideOverCard.swift */; };
2727
D314B66F27D1089200481D5E /* EventStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D314B66E27D1089200481D5E /* EventStore.swift */; };
28+
D3153BC02A8DF850006A2DD8 /* OneSignalFramework in Frameworks */ = {isa = PBXBuildFile; productRef = D3153BBF2A8DF850006A2DD8 /* OneSignalFramework */; };
2829
D318CE44280918C400CEA1AA /* TruncableText.swift in Sources */ = {isa = PBXBuildFile; fileRef = D318CE43280918C400CEA1AA /* TruncableText.swift */; };
2930
D31900D8281CF07E00864982 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D31900D7281CF07E00864982 /* LaunchScreen.storyboard */; };
3031
D322F60F27EF4698007EED5D /* CodeScanner in Frameworks */ = {isa = PBXBuildFile; productRef = D322F60E27EF4698007EED5D /* CodeScanner */; };
@@ -66,7 +67,6 @@
6667
D398F6922A83FD9800FB2912 /* FeatureGridItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D398F6912A83FD9800FB2912 /* FeatureGridItem.swift */; };
6768
D3A00F1F27D837D00097A6AB /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A00F1E27D837D00097A6AB /* NotificationService.swift */; };
6869
D3A00F2327D837D00097A6AB /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D3A00F1C27D837D00097A6AB /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
69-
D3A00F2A27D838920097A6AB /* OneSignal in Frameworks */ = {isa = PBXBuildFile; productRef = D3A00F2927D838920097A6AB /* OneSignal */; };
7070
D3A705612A829334009E5ADF /* EventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A705602A829334009E5ADF /* EventView.swift */; };
7171
D3A705662A82A7D9009E5ADF /* FeatureDestinations.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A705652A82A7D9009E5ADF /* FeatureDestinations.swift */; };
7272
D3A94D03281E62530053FEFA /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3A94D02281E62530053FEFA /* ErrorView.swift */; };
@@ -256,6 +256,7 @@
256256
files = (
257257
D33FB30428C21178006BBEF4 /* FirebasePerformance in Frameworks */,
258258
D322F60F27EF4698007EED5D /* CodeScanner in Frameworks */,
259+
D3153BC02A8DF850006A2DD8 /* OneSignalFramework in Frameworks */,
259260
D3E0123127D35D970040621F /* KeychainAccess in Frameworks */,
260261
D33FB2FE28C21178006BBEF4 /* FirebaseAnalytics in Frameworks */,
261262
D36E33C42A681916006D4159 /* FirebaseAppCheck in Frameworks */,
@@ -264,7 +265,6 @@
264265
D3C0E21A27D51B460095169F /* NetworkExtension.framework in Frameworks */,
265266
D33FB30028C21178006BBEF4 /* FirebaseCrashlytics in Frameworks */,
266267
D3C6F60D28634F3B0074B942 /* MarkdownKit in Frameworks */,
267-
D3A00F2A27D838920097A6AB /* OneSignal in Frameworks */,
268268
D394440D2A75371A00EE2021 /* OrderedCollections in Frameworks */,
269269
D33FB30228C21178006BBEF4 /* FirebaseDynamicLinks in Frameworks */,
270270
);
@@ -627,7 +627,6 @@
627627
packageProductDependencies = (
628628
4F5EB73027D2311200235396 /* SwiftDate */,
629629
D3E0123027D35D970040621F /* KeychainAccess */,
630-
D3A00F2927D838920097A6AB /* OneSignal */,
631630
D322F60E27EF4698007EED5D /* CodeScanner */,
632631
D323C1F4282FE03C009AFF97 /* EFQRCode */,
633632
D3C6F60C28634F3B0074B942 /* MarkdownKit */,
@@ -637,6 +636,7 @@
637636
D33FB30328C21178006BBEF4 /* FirebasePerformance */,
638637
D36E33C32A681916006D4159 /* FirebaseAppCheck */,
639638
D394440C2A75371A00EE2021 /* OrderedCollections */,
639+
D3153BBF2A8DF850006A2DD8 /* OneSignalFramework */,
640640
);
641641
productName = OPass;
642642
productReference = D3E4E6BB27CD158400FFACEB /* OPass.app */;
@@ -1197,7 +1197,7 @@
11971197
repositoryURL = "https://github.com/OneSignal/OneSignal-XCFramework";
11981198
requirement = {
11991199
kind = upToNextMajorVersion;
1200-
minimumVersion = 3.0.0;
1200+
minimumVersion = 5.0.0;
12011201
};
12021202
};
12031203
D3C6F60B28634F3A0074B942 /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
@@ -1224,6 +1224,11 @@
12241224
package = 4F5EB72F27D2311200235396 /* XCRemoteSwiftPackageReference "SwiftDate" */;
12251225
productName = SwiftDate;
12261226
};
1227+
D3153BBF2A8DF850006A2DD8 /* OneSignalFramework */ = {
1228+
isa = XCSwiftPackageProductDependency;
1229+
package = D3A00F2827D838920097A6AB /* XCRemoteSwiftPackageReference "OneSignal-XCFramework" */;
1230+
productName = OneSignalFramework;
1231+
};
12271232
D322F60E27EF4698007EED5D /* CodeScanner */ = {
12281233
isa = XCSwiftPackageProductDependency;
12291234
package = D322F60D27EF4698007EED5D /* XCRemoteSwiftPackageReference "CodeScanner" */;
@@ -1269,11 +1274,6 @@
12691274
package = D394440B2A75371A00EE2021 /* XCRemoteSwiftPackageReference "swift-collections" */;
12701275
productName = OrderedCollections;
12711276
};
1272-
D3A00F2927D838920097A6AB /* OneSignal */ = {
1273-
isa = XCSwiftPackageProductDependency;
1274-
package = D3A00F2827D838920097A6AB /* XCRemoteSwiftPackageReference "OneSignal-XCFramework" */;
1275-
productName = OneSignal;
1276-
};
12771277
D3C6F60C28634F3B0074B942 /* MarkdownKit */ = {
12781278
isa = XCSwiftPackageProductDependency;
12791279
package = D3C6F60B28634F3A0074B942 /* XCRemoteSwiftPackageReference "MarkdownKit" */;

OPass.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@
5959
"kind" : "remoteSourceControl",
6060
"location" : "https://github.com/google/GoogleDataTransport.git",
6161
"state" : {
62-
"revision" : "98a00258d4518b7521253a70b7f70bb76d2120fe",
63-
"version" : "9.2.4"
62+
"revision" : "aae45a320fd0d11811820335b1eabc8753902a40",
63+
"version" : "9.2.5"
6464
}
6565
},
6666
{
6767
"identity" : "googleutilities",
6868
"kind" : "remoteSourceControl",
6969
"location" : "https://github.com/google/GoogleUtilities.git",
7070
"state" : {
71-
"revision" : "58d03d22beae762eaddbd30cb5a61af90d4b309f",
72-
"version" : "7.11.3"
71+
"revision" : "c38ce365d77b04a9a300c31061c5227589e5597b",
72+
"version" : "7.11.5"
7373
}
7474
},
7575
{
@@ -131,17 +131,17 @@
131131
"kind" : "remoteSourceControl",
132132
"location" : "https://github.com/OneSignal/OneSignal-XCFramework",
133133
"state" : {
134-
"revision" : "091f9c572b4a522f93cd1d4f2f524e3818a253f2",
135-
"version" : "3.12.5"
134+
"revision" : "e8300b958a1071307bc73ff861d5a84107c0fd7e",
135+
"version" : "5.0.1"
136136
}
137137
},
138138
{
139139
"identity" : "promises",
140140
"kind" : "remoteSourceControl",
141141
"location" : "https://github.com/google/promises.git",
142142
"state" : {
143-
"revision" : "ec957ccddbcc710ccc64c9dcbd4c7006fcf8b73a",
144-
"version" : "2.2.0"
143+
"revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e",
144+
"version" : "2.3.1"
145145
}
146146
},
147147
{
@@ -158,8 +158,8 @@
158158
"kind" : "remoteSourceControl",
159159
"location" : "https://github.com/apple/swift-protobuf.git",
160160
"state" : {
161-
"revision" : "f25867a208f459d3c5a06935dceb9083b11cd539",
162-
"version" : "1.22.0"
161+
"revision" : "ce20dc083ee485524b802669890291c0d8090170",
162+
"version" : "1.22.1"
163163
}
164164
},
165165
{

OPass/OPassApp.swift

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import OSLog
1111
import SwiftUI
12-
import OneSignal
12+
import OneSignalFramework
1313
import FirebaseCore
1414
import FirebaseAppCheck
1515
import FirebaseAnalytics
@@ -56,39 +56,12 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele
5656

5757
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
5858
// MARK: - Configure OneSignal
59-
let notificationReceiverBlock: OSNotificationWillShowInForegroundBlock = { notification,_ in
60-
self.logger.info("Received Notification - \(notification.notificationId ?? "")")
61-
}
62-
63-
let notificationOpenedBlock: OSNotificationOpenedBlock = { result in
64-
let notification: OSNotification = result.notification
65-
66-
var messageTitle = "OneSignal Message"
67-
var fullMessage = notification.body?.copy() as? String ?? ""
68-
69-
if notification.additionalData != nil {
70-
if notification.title != nil {
71-
messageTitle = notification.title ?? ""
72-
}
73-
74-
if let additionData = notification.additionalData as? Dictionary<String, String> {
75-
if let actionSelected = additionData["actionSelected"] {
76-
fullMessage = "\(fullMessage)\nPressed ButtonId:\(actionSelected)"
77-
}
78-
}
79-
}
80-
self.logger.info("OneSignal Notification \(messageTitle): \(fullMessage)")
81-
}
82-
83-
OneSignal.initWithLaunchOptions(launchOptions)
84-
OneSignal.setAppId("b6213f49-e356-4b48-aa9d-7cf10ce1904d")
85-
OneSignal.setNotificationWillShowInForegroundHandler(notificationReceiverBlock)
86-
OneSignal.setNotificationOpenedHandler(notificationOpenedBlock)
87-
OneSignal.setLocationShared(false)
88-
OneSignal.promptForPushNotifications(userResponse: { accepted in
59+
OneSignal.Debug.setLogLevel(.LL_VERBOSE)
60+
OneSignal.initialize("b6213f49-e356-4b48-aa9d-7cf10ce1904d", withLaunchOptions: launchOptions)
61+
OneSignal.Notifications.requestPermission({ accepted in
8962
self.logger.info("User accepted notifications: \(accepted)")
9063
}, fallbackToSettings: false)
91-
64+
print("#\(OneSignal.User.pushSubscription.id)")
9265
return true
9366
}
9467
}

OPassData/Store/EventStore.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import OSLog
1010
import SwiftUI
1111
import SwiftDate
12-
import OneSignal
12+
import OneSignalFramework
1313
import KeychainAccess
1414
import UserNotifications
1515

@@ -154,7 +154,7 @@ extension EventStore {
154154

155155
do {
156156
let attendee = try await APIManager.fetchAttendee(from: feature, token: token)
157-
OneSignal.sendTag("\(attendee.eventId)\(attendee.role)", value: "\(attendee.token)")
157+
OneSignal.User.addTag(key: "\(attendee.eventId)\(attendee.role)", value: "\(attendee.token)")
158158
DispatchQueue.main.async {
159159
self.attendee = attendee
160160
self.token = token
@@ -315,7 +315,7 @@ extension EventStore {
315315
@inline(__always)
316316
func signOut() {
317317
if let attendee = attendee {
318-
OneSignal.sendTag("\(attendee.eventId)\(attendee.role)", value: "")
318+
OneSignal.User.addTag(key: "\(attendee.eventId)\(attendee.role)", value: "")
319319
self.attendee = nil
320320
self.userId = "nil"
321321
self.userRole = "nil"

0 commit comments

Comments
 (0)