Skip to content

Commit

Permalink
fix(events): duplicated delivered events fix on foreground mode
Browse files Browse the repository at this point in the history
  • Loading branch information
worotyns committed Jun 26, 2023
1 parent c7cb053 commit 4371f6d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion PpgCoreSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "PpgCoreSDK"
spec.version = "0.0.10"
spec.version = "0.0.11"
spec.summary = "PushPushGo Core SDK"

# This description is used to generate tags and improve search results.
Expand Down
5 changes: 3 additions & 2 deletions PpgCoreSDK/Models/DataNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ struct DataNotification: Notification {
return actions
}

func toUNNotificationMutableContent() -> UNMutableNotificationContent {
func toUNNotificationMutableContent(markAsWrapped: Bool = false) -> UNMutableNotificationContent {
let content = UNMutableNotificationContent()


content.userInfo["_wrappedByNSE"] = markAsWrapped ? "1" : nil
content.userInfo["externalData"] = self.externalData
content.userInfo["messageId"] = self.messageId.uuidString
content.userInfo["contextId"] = self.contextId.uuidString
Expand Down
6 changes: 6 additions & 0 deletions PpgCoreSDK/PpgCoreClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ public class PpgCoreClient: NSObject {
case .data:
PpgCoreLogger.info("Got data message from local notifications");
let dataNotification = NotificationFactory.createData(content: notification.request.content)

if (notification.request.content.userInfo["_wrappedByNSE"] != nil) {
PpgCoreLogger.info("Omit, registering delivered event, wrapped by notification wrapped in NSE")
break;
}

onExternalData(dataNotification.externalData)
eventService.send(delivered: dataNotification.createDeliveredEvent())
break;
Expand Down
2 changes: 1 addition & 1 deletion PpgCoreSDK/PpgCoreNotificationServiceExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open class PpgCoreNotificationServiceExtension: UNNotificationServiceExtension {
case .data:
PpgCoreLogger.info("Got data message from remote notifications")
let dataNotification = NotificationFactory.createData(content: request.content)
let newContent = dataNotification.toUNNotificationMutableContent()
let newContent = dataNotification.toUNNotificationMutableContent(markAsWrapped: true)
eventService.send(delivered: dataNotification.createDeliveredEvent())
onExternalData(data: dataNotification.externalData)
contentHandler(newContent);
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Add to your target our library:
```sh
target 'your_project_name' do
use_frameworks!
pod 'PpgCoreSDK', '~> 0.0.10'
pod 'PpgCoreSDK', '~> 0.0.11'
end
```

Expand Down Expand Up @@ -99,7 +99,7 @@ target to `Podfile`:
```sh
target 'NSE' do
use_frameworks!
pod 'PpgCoreSDK', '~> 0.0.10'
pod 'PpgCoreSDK', '~> 0.0.11'
end
```
5. Install pods
Expand Down
4 changes: 2 additions & 2 deletions examples/sdkdemo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ platform :ios, '14.0'

target 'sdkdemo' do
use_frameworks!
pod 'PpgCoreSDK', '~> 0.0.10'
pod 'PpgCoreSDK', '~> 0.0.11'
end

target 'NSE' do
use_frameworks!
pod 'PpgCoreSDK', '~> 0.0.10'
pod 'PpgCoreSDK', '~> 0.0.11'
end
12 changes: 6 additions & 6 deletions examples/sdkdemo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- PpgCoreSDK (0.0.10)
- PpgCoreSDK (0.0.11)

DEPENDENCIES:
- PpgCoreSDK (~> 0.0.10)
- PpgCoreSDK (from `/Users/worotyns/code/ppg/ppg-core-ios-sdk`)

SPEC REPOS:
trunk:
- PpgCoreSDK
EXTERNAL SOURCES:
PpgCoreSDK:
:path: "/Users/worotyns/code/ppg/ppg-core-ios-sdk"

SPEC CHECKSUMS:
PpgCoreSDK: 76c44cf7ddd3afbce74183ed44e9232557011c24

PODFILE CHECKSUM: 7101b6854314b7c7125d0466372b3e2f0161c7b4
PODFILE CHECKSUM: 3745efa55adb0c105591c0ea1c08e0ed3bfcb744

COCOAPODS: 1.12.1
Binary file not shown.

0 comments on commit 4371f6d

Please sign in to comment.