Skip to content

Commit 93f8666

Browse files
Merge branch 'hotfix' into main
2 parents d9f96e8 + 9d971bf commit 93f8666

12 files changed

+699
-669
lines changed

Example/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use_frameworks!
22

3-
platform :ios, '13.0'
3+
platform :ios, '11.0'
44

55
target 'IosAwnCore_Example' do
66
pod 'IosAwnCore', :path => '../'

Example/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PODS:
44
- FBSnapshotTestCase/Core (2.1.4)
55
- FBSnapshotTestCase/SwiftSupport (2.1.4):
66
- FBSnapshotTestCase/Core
7-
- IosAwnCore (0.7.5-dev.2)
7+
- IosAwnCore (0.7.5-dev.3)
88

99
DEPENDENCIES:
1010
- FBSnapshotTestCase (~> 2.1.4)
@@ -20,7 +20,7 @@ EXTERNAL SOURCES:
2020

2121
SPEC CHECKSUMS:
2222
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
23-
IosAwnCore: 76624636cfad2c005c2eea9203bbc6f7a022a680
23+
IosAwnCore: edf31913fd18960ebcde7c05912dc860ca2b63b2
2424

2525
PODFILE CHECKSUM: fc29e9727f005f4a155945343f8282c8133040f5
2626

Example/Pods/Local Podspecs/IosAwnCore.podspec.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/project.pbxproj

+603-595
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IosAwnCore.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'IosAwnCore'
11-
s.version = '0.7.5-dev.2'
11+
s.version = '0.7.5-dev.3'
1212
s.summary = 'Awesome Notifications iOS Core'
1313

1414
s.description = <<-DESC
@@ -24,7 +24,7 @@ Awesome Notifications Ios Core (Only iOS devices).
2424

2525
s.static_framework = true
2626
s.platform = :ios
27-
s.ios.deployment_target = '13.0'
27+
s.ios.deployment_target = '11.0'
2828
s.swift_version = '5.3'
2929

3030
s.source_files = 'IosAwnCore/Classes/**/*'

IosAwnCore/Classes/AwesomeNotifications.swift

+40-26
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ public class AwesomeNotifications:
200200
eventName: lostEvent.eventName,
201201
notificationReceived: lostEvent.notificationContent)
202202
}
203+
204+
RefreshSchedulesReceiver()
205+
.refreshSchedules()
206+
203207
} catch {
204208
if !(error is AwesomeNotificationsException) {
205209
ExceptionFactory
@@ -514,9 +518,6 @@ public class AwesomeNotifications:
514518

515519
UNUserNotificationCenter.current().delegate = self
516520

517-
RefreshSchedulesReceiver()
518-
.refreshSchedules()
519-
520521
AwesomeNotifications.didFinishLaunch = true
521522
if AwesomeNotifications.completionHandlerGetInitialAction != nil {
522523
AwesomeNotifications
@@ -620,33 +621,46 @@ public class AwesomeNotifications:
620621
.jsonDataToNotificationModel(
621622
jsonData: jsonData)
622623
{
623-
StatusBarManager
624-
.shared
625-
.showNotificationOnStatusBar(
626-
withNotificationModel: notificationModel,
627-
whenFinished: { (notificationDisplayed:Bool, mustPlaySound:Bool) in
628-
629-
if !notificationDisplayed && self._originalNotificationCenterDelegate != nil {
630-
self._originalNotificationCenterDelegate?
631-
.userNotificationCenter?(
632-
center,
633-
willPresent: notification,
634-
withCompletionHandler: completionHandler)
635-
}
636-
else {
637-
if notificationDisplayed {
638-
if mustPlaySound {
639-
completionHandler([.alert, .badge, .sound])
624+
do {
625+
try StatusBarManager
626+
.shared
627+
.showNotificationOnStatusBar(
628+
withNotificationModel: notificationModel,
629+
whenFinished: { (notificationDisplayed:Bool, mustPlaySound:Bool) in
630+
631+
if !notificationDisplayed && self._originalNotificationCenterDelegate != nil {
632+
self._originalNotificationCenterDelegate?
633+
.userNotificationCenter?(
634+
center,
635+
willPresent: notification,
636+
withCompletionHandler: completionHandler)
637+
}
638+
else {
639+
if notificationDisplayed {
640+
if mustPlaySound {
641+
completionHandler([.alert, .badge, .sound])
642+
}
643+
else {
644+
completionHandler([.alert, .badge])
645+
}
640646
}
641647
else {
642-
completionHandler([.alert, .badge])
648+
completionHandler([])
643649
}
644650
}
645-
else {
646-
completionHandler([])
647-
}
648-
}
649-
})
651+
})
652+
} catch {
653+
if !(error is AwesomeNotificationsException) {
654+
ExceptionFactory
655+
.shared
656+
.registerNewAwesomeException(
657+
className: TAG,
658+
code: ExceptionCode.CODE_UNKNOWN_EXCEPTION,
659+
message: "An unknow exception was found while displaying a notification on Statusbar",
660+
detailedCode: ExceptionCode.DETAILED_UNEXPECTED_ERROR,
661+
originalException: error)
662+
}
663+
}
650664

651665
}
652666
else {

IosAwnCore/Classes/broadcasters/receivers/NotificationActionReceiver.swift

+18-14
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,24 @@ public class NotificationActionReceiver {
131131
}
132132
}
133133

134-
if !userInfo.isEmpty && notificationModel!.content!.payload == nil {
135-
notificationModel!.content!.payload = [:]
136-
}
137-
for (key, value) in userInfo {
138-
guard let key:String = key as? String
139-
else { continue }
140-
if key == Definitions.NOTIFICATION_JSON { continue }
141-
if key == Definitions.NOTIFICATION_MODEL_CONTENT { continue }
142-
if key == Definitions.NOTIFICATION_MODEL_BUTTONS { continue }
143-
if key == Definitions.NOTIFICATION_MODEL_SCHEDULE { continue }
144-
if key == Definitions.NOTIFICATION_MODEL_ANDROID { continue }
145-
if key == Definitions.NOTIFICATION_MODEL_IOS { continue }
146-
147-
notificationModel!.content!.payload![key] = value as? String
134+
if notificationModel!.content!.createdSource != .Local {
135+
if !userInfo.isEmpty && notificationModel!.content!.payload == nil {
136+
notificationModel!.content!.payload = [:]
137+
}
138+
for (key, value) in userInfo {
139+
guard let key:String = key as? String
140+
else { continue }
141+
if key == Definitions.NOTIFICATION_JSON { continue }
142+
if key == Definitions.NOTIFICATION_MODEL_CONTENT { continue }
143+
if key == Definitions.NOTIFICATION_MODEL_BUTTONS { continue }
144+
if key == Definitions.NOTIFICATION_MODEL_SCHEDULE { continue }
145+
if key == Definitions.NOTIFICATION_MODEL_ANDROID { continue }
146+
if key == Definitions.NOTIFICATION_MODEL_IOS { continue }
147+
if key == Definitions.NOTIFICATION_ID { continue }
148+
if key == Definitions.NOTIFICATION_CHANNEL_KEY { continue }
149+
150+
notificationModel!.content!.payload![key] = value as? String
151+
}
148152
}
149153

150154
guard let actionReceived:ActionReceived =

IosAwnCore/Classes/managers/LostEventsManager.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,28 @@ public class LostEventsManager {
5959
dismissedHandle:Int64
6060
) throws -> [EventRegister] {
6161
var lostEvents:[EventRegister] = []
62-
if actionHandle <= 0 { return lostEvents }
62+
if actionHandle == 0 { return lostEvents }
6363

6464
let locked = recoverLostEventsLock.lock(
6565
before: Date().addingTimeInterval(timeoutLockedProcess)
6666
)
6767
defer { if locked { recoverLostEventsLock.unlock() } }
6868

6969
lostEvents += try recoverLostCreatedEvents(
70-
hasHandleRegistered: createdHandle > 0
70+
hasHandleRegistered: createdHandle != 0
7171
)
7272

7373
lostEvents += try recoverLostDisplayedEvents(
74-
hasHandleRegistered: displayedHandle > 0,
74+
hasHandleRegistered: displayedHandle != 0,
7575
withReferenceLifeCycle: withReferenceLifeCycle
7676
)
7777

7878
lostEvents += try recoverLostDismissedEvents(
79-
hasHandleRegistered: dismissedHandle > 0
79+
hasHandleRegistered: dismissedHandle != 0
8080
)
8181

8282
lostEvents += try recoverLostActionEvents(
83-
hasHandleRegistered: actionHandle > 0
83+
hasHandleRegistered: actionHandle != 0
8484
)
8585

8686
return lostEvents.sorted()

IosAwnCore/Classes/managers/StatusBarManager.swift

+17-17
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class StatusBarManager {
7575
public func showNotificationOnStatusBar(
7676
withNotificationModel notificationModel: NotificationModel,
7777
whenFinished completionHandler: @escaping (Bool, Bool) -> Void
78-
) {
78+
) throws {
7979

8080
/*
8181
if(content.userInfo["updated"] == nil){
@@ -105,22 +105,22 @@ public class StatusBarManager {
105105
}
106106
*/
107107

108-
let notificationReceived:NotificationReceived? = NotificationReceived(notificationModel.content)
109-
if(notificationReceived != nil){
110-
111-
notificationModel.content!.displayedLifeCycle = LifeCycleManager.shared.currentLifeCycle
112-
113-
let channel:NotificationChannelModel? =
114-
ChannelManager
115-
.shared
116-
.getChannelByKey(channelKey: notificationModel.content!.channelKey!)
117-
118-
alertOnlyOnceNotification(
119-
channel?.onlyAlertOnce,
120-
notificationReceived: notificationReceived!,
121-
completionHandler: completionHandler
122-
)
123-
}
108+
let notificationReceived = NotificationReceived(notificationModel.content)
109+
try notificationReceived.validate()
110+
111+
notificationReceived.displayedLifeCycle = LifeCycleManager.shared.currentLifeCycle
112+
113+
guard let channel:NotificationChannelModel =
114+
ChannelManager
115+
.shared
116+
.getChannelByKey(channelKey: notificationReceived.channelKey ?? "")
117+
else { return }
118+
119+
alertOnlyOnceNotification(
120+
channel.onlyAlertOnce,
121+
notificationReceived: notificationReceived,
122+
completionHandler: completionHandler
123+
)
124124
}
125125

126126
@available(iOS 10.0, *)

IosAwnCore/Classes/models/returnedData/ActionReceived.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public class ActionReceived : NotificationReceived {
3939
if arguments?.isEmpty ?? true { return nil }
4040

4141
do {
42-
self.init(fromMap: arguments)
42+
guard let contentModel = NotificationReceived(fromMap: arguments) else { return nil }
43+
self.init(contentModel)
44+
4345
self.buttonKeyPressed = MapUtils<String>.getValueOrDefault(reference: Definitions.NOTIFICATION_BUTTON_KEY_PRESSED, arguments: arguments)
4446
self.buttonKeyInput = MapUtils<String>.getValueOrDefault(reference: Definitions.NOTIFICATION_BUTTON_KEY_INPUT, arguments: arguments)
4547

IosAwnCore/Classes/models/returnedData/NotificationReceived.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import Foundation
99

1010
public class NotificationReceived : NotificationContentModel {
11-
11+
1212
public convenience init?(fromMap arguments: [String : Any?]?){
1313
if arguments?.isEmpty ?? true { return nil }
14-
self.init(fromMap: arguments)
14+
15+
guard let contentModel = NotificationContentModel(fromMap: arguments) else { return nil }
16+
self.init(contentModel)
1517
}
1618

1719
init(_ contentModel:NotificationContentModel?){

0 commit comments

Comments
 (0)