Skip to content

Commit

Permalink
Tmp commit to reproduce crash in issue #593 and #1380
Browse files Browse the repository at this point in the history
  • Loading branch information
maratal committed Dec 30, 2022
1 parent c20129b commit fec6394
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Examples/AblyPush/AblyPushExample/AblyHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class AblyHelper: NSObject {

static let shared = AblyHelper(clientId: UIDevice.current.name)

private var clientId: String!

private(set) var realtime: ARTRealtime!

private var testChannel: ARTRealtimeChannel {
Expand All @@ -13,15 +15,20 @@ class AblyHelper: NSObject {

private let key = "" // Your API Key from your app's dashboard

func createRealtime() {
self.realtime?.close()
let options = ARTClientOptions(key: key)
options.clientId = clientId
options.pushRegistererDelegate = self
self.realtime = ARTRealtime(options: options)
}

private convenience init(clientId: String) {
self.init()
guard key != "" else {
preconditionFailure("Obtain your API key at https://ably.com/accounts/")
}
let options = ARTClientOptions(key: key)
options.clientId = clientId
options.pushRegistererDelegate = self
self.realtime = ARTRealtime(options: options)
self.clientId = clientId
UNUserNotificationCenter.current().delegate = self
}
}
Expand Down
7 changes: 7 additions & 0 deletions Examples/AblyPush/AblyPushExample/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
ARTPush.didFailToRegisterForRemoteNotificationsWithError(error, realtime: AblyHelper.shared.realtime)
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: nil) { n in
AblyHelper.shared.createRealtime()
}
return true
}
}

0 comments on commit fec6394

Please sign in to comment.