Skip to content

Commit

Permalink
Merge branch 'hotfix' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelsetragni committed Jun 4, 2023
2 parents d9f96e8 + 9d971bf commit 93f8666
Show file tree
Hide file tree
Showing 12 changed files with 699 additions and 669 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use_frameworks!

platform :ios, '13.0'
platform :ios, '11.0'

target 'IosAwnCore_Example' do
pod 'IosAwnCore', :path => '../'
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PODS:
- FBSnapshotTestCase/Core (2.1.4)
- FBSnapshotTestCase/SwiftSupport (2.1.4):
- FBSnapshotTestCase/Core
- IosAwnCore (0.7.5-dev.2)
- IosAwnCore (0.7.5-dev.3)

DEPENDENCIES:
- FBSnapshotTestCase (~> 2.1.4)
Expand All @@ -20,7 +20,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
IosAwnCore: 76624636cfad2c005c2eea9203bbc6f7a022a680
IosAwnCore: edf31913fd18960ebcde7c05912dc860ca2b63b2

PODFILE CHECKSUM: fc29e9727f005f4a155945343f8282c8133040f5

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/IosAwnCore.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,198 changes: 603 additions & 595 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions IosAwnCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'IosAwnCore'
s.version = '0.7.5-dev.2'
s.version = '0.7.5-dev.3'
s.summary = 'Awesome Notifications iOS Core'

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

s.static_framework = true
s.platform = :ios
s.ios.deployment_target = '13.0'
s.ios.deployment_target = '11.0'
s.swift_version = '5.3'

s.source_files = 'IosAwnCore/Classes/**/*'
Expand Down
66 changes: 40 additions & 26 deletions IosAwnCore/Classes/AwesomeNotifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ public class AwesomeNotifications:
eventName: lostEvent.eventName,
notificationReceived: lostEvent.notificationContent)
}

RefreshSchedulesReceiver()
.refreshSchedules()

} catch {
if !(error is AwesomeNotificationsException) {
ExceptionFactory
Expand Down Expand Up @@ -514,9 +518,6 @@ public class AwesomeNotifications:

UNUserNotificationCenter.current().delegate = self

RefreshSchedulesReceiver()
.refreshSchedules()

AwesomeNotifications.didFinishLaunch = true
if AwesomeNotifications.completionHandlerGetInitialAction != nil {
AwesomeNotifications
Expand Down Expand Up @@ -620,33 +621,46 @@ public class AwesomeNotifications:
.jsonDataToNotificationModel(
jsonData: jsonData)
{
StatusBarManager
.shared
.showNotificationOnStatusBar(
withNotificationModel: notificationModel,
whenFinished: { (notificationDisplayed:Bool, mustPlaySound:Bool) in

if !notificationDisplayed && self._originalNotificationCenterDelegate != nil {
self._originalNotificationCenterDelegate?
.userNotificationCenter?(
center,
willPresent: notification,
withCompletionHandler: completionHandler)
}
else {
if notificationDisplayed {
if mustPlaySound {
completionHandler([.alert, .badge, .sound])
do {
try StatusBarManager
.shared
.showNotificationOnStatusBar(
withNotificationModel: notificationModel,
whenFinished: { (notificationDisplayed:Bool, mustPlaySound:Bool) in

if !notificationDisplayed && self._originalNotificationCenterDelegate != nil {
self._originalNotificationCenterDelegate?
.userNotificationCenter?(
center,
willPresent: notification,
withCompletionHandler: completionHandler)
}
else {
if notificationDisplayed {
if mustPlaySound {
completionHandler([.alert, .badge, .sound])
}
else {
completionHandler([.alert, .badge])
}
}
else {
completionHandler([.alert, .badge])
completionHandler([])
}
}
else {
completionHandler([])
}
}
})
})
} catch {
if !(error is AwesomeNotificationsException) {
ExceptionFactory
.shared
.registerNewAwesomeException(
className: TAG,
code: ExceptionCode.CODE_UNKNOWN_EXCEPTION,
message: "An unknow exception was found while displaying a notification on Statusbar",
detailedCode: ExceptionCode.DETAILED_UNEXPECTED_ERROR,
originalException: error)
}
}

}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,24 @@ public class NotificationActionReceiver {
}
}

if !userInfo.isEmpty && notificationModel!.content!.payload == nil {
notificationModel!.content!.payload = [:]
}
for (key, value) in userInfo {
guard let key:String = key as? String
else { continue }
if key == Definitions.NOTIFICATION_JSON { continue }
if key == Definitions.NOTIFICATION_MODEL_CONTENT { continue }
if key == Definitions.NOTIFICATION_MODEL_BUTTONS { continue }
if key == Definitions.NOTIFICATION_MODEL_SCHEDULE { continue }
if key == Definitions.NOTIFICATION_MODEL_ANDROID { continue }
if key == Definitions.NOTIFICATION_MODEL_IOS { continue }

notificationModel!.content!.payload![key] = value as? String
if notificationModel!.content!.createdSource != .Local {
if !userInfo.isEmpty && notificationModel!.content!.payload == nil {
notificationModel!.content!.payload = [:]
}
for (key, value) in userInfo {
guard let key:String = key as? String
else { continue }
if key == Definitions.NOTIFICATION_JSON { continue }
if key == Definitions.NOTIFICATION_MODEL_CONTENT { continue }
if key == Definitions.NOTIFICATION_MODEL_BUTTONS { continue }
if key == Definitions.NOTIFICATION_MODEL_SCHEDULE { continue }
if key == Definitions.NOTIFICATION_MODEL_ANDROID { continue }
if key == Definitions.NOTIFICATION_MODEL_IOS { continue }
if key == Definitions.NOTIFICATION_ID { continue }
if key == Definitions.NOTIFICATION_CHANNEL_KEY { continue }

notificationModel!.content!.payload![key] = value as? String
}
}

guard let actionReceived:ActionReceived =
Expand Down
10 changes: 5 additions & 5 deletions IosAwnCore/Classes/managers/LostEventsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@ public class LostEventsManager {
dismissedHandle:Int64
) throws -> [EventRegister] {
var lostEvents:[EventRegister] = []
if actionHandle <= 0 { return lostEvents }
if actionHandle == 0 { return lostEvents }

let locked = recoverLostEventsLock.lock(
before: Date().addingTimeInterval(timeoutLockedProcess)
)
defer { if locked { recoverLostEventsLock.unlock() } }

lostEvents += try recoverLostCreatedEvents(
hasHandleRegistered: createdHandle > 0
hasHandleRegistered: createdHandle != 0
)

lostEvents += try recoverLostDisplayedEvents(
hasHandleRegistered: displayedHandle > 0,
hasHandleRegistered: displayedHandle != 0,
withReferenceLifeCycle: withReferenceLifeCycle
)

lostEvents += try recoverLostDismissedEvents(
hasHandleRegistered: dismissedHandle > 0
hasHandleRegistered: dismissedHandle != 0
)

lostEvents += try recoverLostActionEvents(
hasHandleRegistered: actionHandle > 0
hasHandleRegistered: actionHandle != 0
)

return lostEvents.sorted()
Expand Down
34 changes: 17 additions & 17 deletions IosAwnCore/Classes/managers/StatusBarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class StatusBarManager {
public func showNotificationOnStatusBar(
withNotificationModel notificationModel: NotificationModel,
whenFinished completionHandler: @escaping (Bool, Bool) -> Void
) {
) throws {

/*
if(content.userInfo["updated"] == nil){
Expand Down Expand Up @@ -105,22 +105,22 @@ public class StatusBarManager {
}
*/

let notificationReceived:NotificationReceived? = NotificationReceived(notificationModel.content)
if(notificationReceived != nil){
notificationModel.content!.displayedLifeCycle = LifeCycleManager.shared.currentLifeCycle
let channel:NotificationChannelModel? =
ChannelManager
.shared
.getChannelByKey(channelKey: notificationModel.content!.channelKey!)
alertOnlyOnceNotification(
channel?.onlyAlertOnce,
notificationReceived: notificationReceived!,
completionHandler: completionHandler
)
}
let notificationReceived = NotificationReceived(notificationModel.content)
try notificationReceived.validate()

notificationReceived.displayedLifeCycle = LifeCycleManager.shared.currentLifeCycle

guard let channel:NotificationChannelModel =
ChannelManager
.shared
.getChannelByKey(channelKey: notificationReceived.channelKey ?? "")
else { return }

alertOnlyOnceNotification(
channel.onlyAlertOnce,
notificationReceived: notificationReceived,
completionHandler: completionHandler
)
}

@available(iOS 10.0, *)
Expand Down
4 changes: 3 additions & 1 deletion IosAwnCore/Classes/models/returnedData/ActionReceived.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class ActionReceived : NotificationReceived {
if arguments?.isEmpty ?? true { return nil }

do {
self.init(fromMap: arguments)
guard let contentModel = NotificationReceived(fromMap: arguments) else { return nil }
self.init(contentModel)

self.buttonKeyPressed = MapUtils<String>.getValueOrDefault(reference: Definitions.NOTIFICATION_BUTTON_KEY_PRESSED, arguments: arguments)
self.buttonKeyInput = MapUtils<String>.getValueOrDefault(reference: Definitions.NOTIFICATION_BUTTON_KEY_INPUT, arguments: arguments)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import Foundation

public class NotificationReceived : NotificationContentModel {

public convenience init?(fromMap arguments: [String : Any?]?){
if arguments?.isEmpty ?? true { return nil }
self.init(fromMap: arguments)

guard let contentModel = NotificationContentModel(fromMap: arguments) else { return nil }
self.init(contentModel)
}

init(_ contentModel:NotificationContentModel?){
Expand Down

0 comments on commit 93f8666

Please sign in to comment.