Skip to content

Commit

Permalink
Integrated Push Notifications
Browse files Browse the repository at this point in the history
 Removed unused code

Signed-off-by: kcw-grunt <[email protected]>
  • Loading branch information
kcw-grunt committed Dec 3, 2023
1 parent ea32dc6 commit bb8b5e0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 89 deletions.
29 changes: 27 additions & 2 deletions litewallet/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let applicationController = ApplicationController()
// FIXME: - Waiting for Pusher to respond: https://github.com/pusher/push-notifications-swift/issues/187
// let pushNotifications = PushNotifications.shared
let pushNotifications = PushNotifications.shared

func application(_ application: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
Expand Down Expand Up @@ -37,7 +37,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

Bundle.setLanguage(UserDefaults.selectedLanguage)

// "bbac5210-989c-49d5-a336-ae1eaf81e586"
// Pusher
pushNotifications.start(instanceId: "bbac5210-989c-49d5-a336-ae1eaf81e586")
pushNotifications.registerForRemoteNotifications()

let generaliOSInterest = "general-ios"
let debugGeneraliOSInterest = "debug-general-ios"

try? pushNotifications
.addDeviceInterest(interest: generaliOSInterest)
try? pushNotifications
.addDeviceInterest(interest: debugGeneraliOSInterest)

let interests = pushNotifications.getDeviceInterests()?.joined(separator: "|") ?? ""
let device = UIDevice.current.identifierForVendor?.uuidString ?? "ID"
let interestesDict: [String: String] = ["device_id": device,
"pusher_interests": interests]

LWAnalytics.logEventWithParameters(itemName: ._20231202_RIGI, properties: interestesDict)

return true
}
Expand Down Expand Up @@ -81,6 +98,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

func application(_: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
pushNotifications.registerDeviceToken(deviceToken)
}

func application(_: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler _: @escaping (UIBackgroundFetchResult) -> Void) {
pushNotifications.handleNotification(userInfo: userInfo)
}

/// Sets the correct Google Services plist file
private func setFirebaseConfiguration() {
// Load a Firebase debug config file.
Expand Down
3 changes: 3 additions & 0 deletions litewallet/src/Constants/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ enum CustomEvent: String {

/// User Tapped on UD Image
case _20220822_UTOU = "user_tapped_on_ud"

/// User registered Pusher interest
case _20231202_RIGI = "registered_ios_general_interest"
}

struct FoundationSupport {
Expand Down
9 changes: 0 additions & 9 deletions litewallet/src/SimpleRedux/Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,6 @@ enum MaxDigits {
}
}

enum PushNotifications {
struct setIsEnabled: Action {
let reduce: Reducer
init(_ isEnabled: Bool) {
reduce = { $0.clone(isPushNotificationsEnabled: isEnabled) }
}
}
}

enum biometricsActions {
struct setIsPrompting: Action {
let reduce: Reducer
Expand Down

This file was deleted.

0 comments on commit bb8b5e0

Please sign in to comment.