mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 23:27:26 +01:00
FIX: Apple Watch app not working #5470
This commit is contained in:
parent
c1af945439
commit
eb8f4ded4a
5 changed files with 40 additions and 33 deletions
|
@ -103,7 +103,7 @@
|
|||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
if ([[WCSession defaultSession] isReachable]) {
|
||||
if ([WCSession defaultSession].activationState == WCSessionActivationStateActivated && [[WCSession defaultSession] isReachable]) {
|
||||
[WCSession.defaultSession updateApplicationContext:@{@"isWalletsInitialized": @NO} error:nil];
|
||||
}
|
||||
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.io.bluewallet.bluewallet"];
|
||||
|
|
|
@ -176,6 +176,7 @@
|
|||
</array>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
<string>remote-notification</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
|
|
|
@ -10,12 +10,23 @@ import WatchKit
|
|||
import WatchConnectivity
|
||||
import Foundation
|
||||
|
||||
class InterfaceController: WKInterfaceController {
|
||||
class InterfaceController: WKInterfaceController, WCSessionDelegate {
|
||||
|
||||
@IBOutlet weak var walletsTable: WKInterfaceTable!
|
||||
@IBOutlet weak var noWalletsAvailableLabel: WKInterfaceLabel!
|
||||
private let userActivity: NSUserActivity = NSUserActivity(activityType: HandoffIdentifier.ReceiveOnchain.rawValue)
|
||||
|
||||
var session: WCSession?
|
||||
|
||||
override func awake(withContext context: Any?) {
|
||||
super.awake(withContext: context)
|
||||
if WCSession.isSupported() {
|
||||
print("Activating watch session")
|
||||
self.session = WCSession.default
|
||||
self.session?.delegate = self
|
||||
self.session?.activate()
|
||||
}
|
||||
}
|
||||
|
||||
override func willActivate() {
|
||||
// This method is called when watch view controller is about to be visible to user
|
||||
super.willActivate()
|
||||
|
@ -54,4 +65,26 @@ class InterfaceController: WKInterfaceController {
|
|||
return rowIndex;
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) {
|
||||
WatchDataSource.shared.processData(data: applicationContext)
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
|
||||
WatchDataSource.shared.processData(data: applicationContext)
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : Any] = [:]) {
|
||||
WatchDataSource.shared.processData(data: userInfo)
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
|
||||
if activationState == .activated {
|
||||
WCSession.default.sendMessage(["message" : "sendApplicationContext"], replyHandler: { (replyData) in
|
||||
}) { (error) in
|
||||
print(error)
|
||||
}
|
||||
} else {
|
||||
WatchDataSource.shared.companionWalletsInitialized = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import Foundation
|
||||
import WatchConnectivity
|
||||
|
||||
class WatchDataSource: NSObject, WCSessionDelegate {
|
||||
class WatchDataSource: NSObject {
|
||||
struct NotificationName {
|
||||
static let dataUpdated = Notification.Name(rawValue: "Notification.WalletDataSource.Updated")
|
||||
}
|
||||
|
@ -30,11 +30,6 @@ class WatchDataSource: NSObject, WCSessionDelegate {
|
|||
wallets = walletData
|
||||
WatchDataSource.postDataUpdatedNotification()
|
||||
}
|
||||
if WCSession.isSupported() {
|
||||
print("Activating watch session")
|
||||
WCSession.default.delegate = self
|
||||
WCSession.default.activate()
|
||||
}
|
||||
}
|
||||
|
||||
func processWalletsData(walletsInfo: [String: Any]) {
|
||||
|
@ -100,14 +95,7 @@ class WatchDataSource: NSObject, WCSessionDelegate {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) {
|
||||
processData(data: applicationContext)
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
|
||||
processData(data: applicationContext)
|
||||
}
|
||||
|
||||
|
||||
func processData(data: [String: Any]) {
|
||||
if let preferredFiatCurrency = data["preferredFiatCurrency"] as? String, let preferredFiatCurrencyUnit = fiatUnit(currency: preferredFiatCurrency) {
|
||||
|
@ -122,19 +110,4 @@ class WatchDataSource: NSObject, WCSessionDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : Any] = [:]) {
|
||||
processData(data: userInfo)
|
||||
}
|
||||
|
||||
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
|
||||
if activationState == .activated {
|
||||
WCSession.default.sendMessage(["message" : "sendApplicationContext"], replyHandler: { (replyData) in
|
||||
}) { (error) in
|
||||
print(error)
|
||||
}
|
||||
} else {
|
||||
WatchDataSource.shared.companionWalletsInitialized = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class ViewQRCodefaceController: WKInterfaceController {
|
|||
|
||||
DispatchQueue.main.async {
|
||||
guard let cgImage = EFQRCode.generate(
|
||||
content: passedContext) else {
|
||||
for: passedContext) else {
|
||||
return
|
||||
}
|
||||
let image = UIImage(cgImage: cgImage)
|
||||
|
|
Loading…
Add table
Reference in a new issue