Skip to content

Commit 9d16244

Browse files
committed
fix: 拆分订阅模型元数据扩展
1 parent 04d4720 commit 9d16244

1 file changed

Lines changed: 84 additions & 80 deletions

File tree

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModel.swift

Lines changed: 84 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -345,86 +345,6 @@ class OSSubscriptionModel: OSModel {
345345
}
346346
}
347347

348-
var deviceOs: String {
349-
get {
350-
stateLock.withLock {
351-
state.deviceOs
352-
}
353-
}
354-
set {
355-
withMutationLock {
356-
guard update(\.deviceOs, to: newValue) != nil else {
357-
return
358-
}
359-
self.set(property: "deviceOs", newValue: newValue)
360-
}
361-
}
362-
}
363-
364-
var sdk: String {
365-
get {
366-
stateLock.withLock {
367-
state.sdk
368-
}
369-
}
370-
set {
371-
withMutationLock {
372-
guard update(\.sdk, to: newValue) != nil else {
373-
return
374-
}
375-
self.set(property: "sdk", newValue: newValue)
376-
}
377-
}
378-
}
379-
380-
var deviceModel: String? {
381-
get {
382-
stateLock.withLock {
383-
state.deviceModel
384-
}
385-
}
386-
set {
387-
withMutationLock {
388-
guard update(\.deviceModel, to: newValue) != nil else {
389-
return
390-
}
391-
self.set(property: "deviceModel", newValue: newValue)
392-
}
393-
}
394-
}
395-
396-
var appVersion: String? {
397-
get {
398-
stateLock.withLock {
399-
state.appVersion
400-
}
401-
}
402-
set {
403-
withMutationLock {
404-
guard update(\.appVersion, to: newValue) != nil else {
405-
return
406-
}
407-
self.set(property: "appVersion", newValue: newValue)
408-
}
409-
}
410-
}
411-
412-
var netType: Int? {
413-
get {
414-
stateLock.withLock {
415-
state.netType
416-
}
417-
}
418-
set {
419-
withMutationLock {
420-
guard update(\.netType, to: newValue) != nil else {
421-
return
422-
}
423-
self.set(property: "netType", newValue: newValue)
424-
}
425-
}
426-
}
427-
428348
// When a Subscription is initialized, it may not have a subscriptionId until a request to the backend is made.
429349
init(type: OSSubscriptionType,
430350
address: String?,
@@ -574,6 +494,90 @@ class OSSubscriptionModel: OSModel {
574494
}
575495
}
576496

497+
// MARK: - Subscription Metadata
498+
499+
extension OSSubscriptionModel {
500+
var deviceOs: String {
501+
get {
502+
stateLock.withLock {
503+
state.deviceOs
504+
}
505+
}
506+
set {
507+
withMutationLock {
508+
guard update(\.deviceOs, to: newValue) != nil else {
509+
return
510+
}
511+
self.set(property: "deviceOs", newValue: newValue)
512+
}
513+
}
514+
}
515+
516+
var sdk: String {
517+
get {
518+
stateLock.withLock {
519+
state.sdk
520+
}
521+
}
522+
set {
523+
withMutationLock {
524+
guard update(\.sdk, to: newValue) != nil else {
525+
return
526+
}
527+
self.set(property: "sdk", newValue: newValue)
528+
}
529+
}
530+
}
531+
532+
var deviceModel: String? {
533+
get {
534+
stateLock.withLock {
535+
state.deviceModel
536+
}
537+
}
538+
set {
539+
withMutationLock {
540+
guard update(\.deviceModel, to: newValue) != nil else {
541+
return
542+
}
543+
self.set(property: "deviceModel", newValue: newValue)
544+
}
545+
}
546+
}
547+
548+
var appVersion: String? {
549+
get {
550+
stateLock.withLock {
551+
state.appVersion
552+
}
553+
}
554+
set {
555+
withMutationLock {
556+
guard update(\.appVersion, to: newValue) != nil else {
557+
return
558+
}
559+
self.set(property: "appVersion", newValue: newValue)
560+
}
561+
}
562+
}
563+
564+
var netType: Int? {
565+
get {
566+
stateLock.withLock {
567+
state.netType
568+
}
569+
}
570+
set {
571+
withMutationLock {
572+
guard update(\.netType, to: newValue) != nil else {
573+
return
574+
}
575+
self.set(property: "netType", newValue: newValue)
576+
}
577+
}
578+
}
579+
}
580+
577581
// Push Subscription related
578582
extension OSSubscriptionModel {
579583
// Only used for the push subscription model

0 commit comments

Comments
 (0)