-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/push-notifications-ext' into feature/push-notif…
…ications-open-screen # Conflicts: # NovaPushNotificationServiceExtension/Handlers/Transfers/TransferType.swift # novawallet.xcodeproj/project.pbxproj # novawallet/Modules/Notifications/NotificationHandlers/Payload.swift
- Loading branch information
Showing
46 changed files
with
788 additions
and
816 deletions.
There are no files selected for viewing
43 changes: 0 additions & 43 deletions
43
NovaPushNotificationServiceExtension/CurrencyRepository.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
NovaPushNotificationServiceExtension/Handlers/LocalizationKeys.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
NovaPushNotificationServiceExtension/Handlers/Transfers/TransferType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Foundation | ||
|
||
enum TransferType { | ||
case income | ||
case outcome | ||
|
||
func title(locale: Locale, walletName: String?) -> String { | ||
let walletString = walletName.flatMap { "[\($0)]" } ?? "" | ||
let title: String | ||
switch self { | ||
case .income: | ||
title = R.string.localizable.pushNotificationReceiveTokensTitle(preferredLanguages: locale.rLanguages) | ||
case .outcome: | ||
title = R.string.localizable.pushNotificationSentTokensTitle(preferredLanguages: locale.rLanguages) | ||
} | ||
|
||
return [title, walletString].joined(with: .space) | ||
} | ||
|
||
func subtitle( | ||
amount: String, | ||
price: String?, | ||
chainName: String, | ||
address: AccountAddress?, | ||
locale: Locale | ||
) -> String { | ||
let priceString = price.map { "(\($0))" } ?? "" | ||
switch self { | ||
case .income: | ||
return R.string.localizable.pushNotificationReceiveTokensSubtitle( | ||
amount, | ||
priceString, | ||
chainName, | ||
preferredLanguages: locale.rLanguages | ||
) | ||
case .outcome: | ||
if let address = address { | ||
return R.string.localizable.pushNotificationSentTokensSubtitle( | ||
amount, | ||
priceString, | ||
address, | ||
chainName, | ||
preferredLanguages: locale.rLanguages | ||
) | ||
} else { | ||
return R.string.localizable.pushNotificationSentTokensWoAddressSubtitle( | ||
amount, | ||
priceString, | ||
chainName, | ||
preferredLanguages: locale.rLanguages | ||
) | ||
} | ||
} | ||
} | ||
|
||
func address(from payload: NotificationTransferPayload) -> AccountAddress? { | ||
switch self { | ||
case .income: | ||
return nil | ||
case .outcome: | ||
return payload.recipient | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
NovaPushNotificationServiceExtension/Model/NotificationContentResult+UserContent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import UserNotifications | ||
|
||
extension NotificationContentResult { | ||
func toUserNotificationContent() -> UNNotificationContent { | ||
let content = UNMutableNotificationContent() | ||
content.title = title | ||
content.subtitle = "" | ||
content.body = subtitle | ||
|
||
return content | ||
} | ||
} |
Oops, something went wrong.