commit
a761fcb86a
@ -1,21 +0,0 @@ |
||||
{ |
||||
"images" : [ |
||||
{ |
||||
"idiom" : "universal", |
||||
"scale" : "1x" |
||||
}, |
||||
{ |
||||
"idiom" : "universal", |
||||
"scale" : "2x" |
||||
}, |
||||
{ |
||||
"idiom" : "universal", |
||||
"filename" : "settings_push_notifications.png", |
||||
"scale" : "3x" |
||||
} |
||||
], |
||||
"info" : { |
||||
"version" : 1, |
||||
"author" : "xcode" |
||||
} |
||||
} |
Before Width: | Height: | Size: 862 B |
@ -1,52 +0,0 @@ |
||||
// Copyright SIX DAY LLC. All rights reserved. |
||||
|
||||
import Foundation |
||||
import UserNotifications |
||||
import UIKit |
||||
import Moya |
||||
import TrustKeystore |
||||
|
||||
class PushNotificationsRegistrar { |
||||
|
||||
private let trustProvider = TrustProviderFactory.makeProvider() |
||||
let config = Config() |
||||
|
||||
var isRegisteredForRemoteNotifications: Bool { |
||||
return UIApplication.shared.isRegisteredForRemoteNotifications |
||||
} |
||||
|
||||
func reRegister() { |
||||
guard isRegisteredForRemoteNotifications else { return } |
||||
register() |
||||
} |
||||
|
||||
func register() { |
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound]) { _, _ in } |
||||
UIApplication.shared.registerForRemoteNotifications() |
||||
} |
||||
|
||||
func unregister() { |
||||
let device = PushDevice( |
||||
deviceID: UIDevice.current.identifierForVendor!.uuidString, |
||||
token: "", |
||||
wallets: [] |
||||
) |
||||
|
||||
trustProvider.request(.unregister(device: device)) { _ in } |
||||
UIApplication.shared.unregisterForRemoteNotifications() |
||||
} |
||||
|
||||
func didRegister(with deviceToken: Data, addresses: [Address]) { |
||||
let token = deviceToken.map { data -> String in |
||||
return String(format: "%02.2hhx", data) |
||||
}.joined() |
||||
|
||||
let device = PushDevice( |
||||
deviceID: UIDevice.current.identifierForVendor!.uuidString, |
||||
token: token, |
||||
wallets: addresses.map { $0.description } |
||||
) |
||||
|
||||
trustProvider.request(.register(device: device)) { _ in } |
||||
} |
||||
} |
Loading…
Reference in new issue