Skip to content

Commit

Permalink
Updated library (2.1.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcorrads committed Aug 21, 2020
1 parent c1037b5 commit b27ae7d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
48 changes: 25 additions & 23 deletions Service/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,44 @@ import UserNotifications

class NotificationService: CatapushNotificationServiceExtension {

private var contentHandler: ((UNNotificationContent) -> Void)?
private var bestAttemptContent: UNMutableNotificationContent?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler;
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
super.didReceive(request, withContentHandler: contentHandler)
}
override func handleMessage(_ message: MessageIP!) {

override func handleMessage(_ message: MessageIP?, withContentHandler contentHandler: ((UNNotificationContent?) -> Void)?, withBestAttempt bestAttemptContent: UNMutableNotificationContent?) {
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
if (message != nil) {
bestAttemptContent.body = message.body;
bestAttemptContent.body = message!.body;
}else{
bestAttemptContent.body = "No new message";
}
contentHandler(bestAttemptContent);
}
}

override func handleError(_ error: Error!) {
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
if (error._code == CatapushCredentialsError) {
bestAttemptContent.body = "User not logged in";
}
if (error._code == CatapushNetworkError) {
bestAttemptContent.body = "Network error";
}
if (error._code == CatapushNoMessagesError) {
bestAttemptContent.body = "No new message";
}
if (error._code == CatapushFileProtectionError) {

override func handleError(_ error: Error, withContentHandler contentHandler: ((UNNotificationContent?) -> Void)?, withBestAttempt bestAttemptContent: UNMutableNotificationContent?) {
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent{
let errorCode = (error as NSError).code
if (errorCode == CatapushCredentialsError) {
bestAttemptContent.body = "User not logged in";
}
if (errorCode == CatapushNetworkError) {
bestAttemptContent.body = "Network error";
}
if (errorCode == CatapushNoMessagesError) {
bestAttemptContent.body = "No new message";
}
if (errorCode == CatapushFileProtectionError) {
bestAttemptContent.body = "Unlock the device at least once to receive the message";
}
contentHandler(bestAttemptContent);
if (errorCode == CatapushConflictErrorCode) {
bestAttemptContent.body = "Connected from another resource";
}
if (errorCode == CatapushAppIsActive) {
bestAttemptContent.body = "Please open the app to read the message";
}
contentHandler(bestAttemptContent);
}
}

}
4 changes: 2 additions & 2 deletions catapush-ios-swift-sdk-example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-catapush-ios-swift-sdk-example/Pods-catapush-ios-swift-sdk-example-resources.sh",
"${PODS_ROOT}/../../catapush-ios-sdk-pod/CatapushKit/CatapushLibBundle.bundle",
"${PODS_ROOT}/catapush-ios-sdk-pod/CatapushKit/CatapushLibBundle.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
Expand Down Expand Up @@ -360,7 +360,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Service/Pods-Service-resources.sh",
"${PODS_ROOT}/../../catapush-ios-sdk-pod/CatapushKit/CatapushLibBundle.bundle",
"${PODS_ROOT}/catapush-ios-sdk-pod/CatapushKit/CatapushLibBundle.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
Expand Down

0 comments on commit b27ae7d

Please sign in to comment.