Skip to content

Commit 014d102

Browse files
committed
Update Swift example to work with changes
1 parent 30360bf commit 014d102

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

iOS Example Swift/iOS Example Swift/AppDelegate.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import PusherSwift
1111
import UserNotifications
1212

1313
@UIApplicationMain
14-
class AppDelegate: UIResponder, UIApplicationDelegate {
14+
class AppDelegate: UIResponder, UIApplicationDelegate, PusherDelegate {
1515

1616
var window: UIWindow?
1717
let pusher = Pusher(key: "YOUR_APP_KEY")
@@ -27,8 +27,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2727
}
2828

2929
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
30-
pusher.nativePusher().register(deviceToken: deviceToken)
31-
pusher.nativePusher().subscribe(interestName: "donuts")
30+
pusher.nativePusher.register(deviceToken: deviceToken)
31+
pusher.nativePusher.subscribe(interestName: "donuts")
3232
}
3333

3434
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
@@ -61,4 +61,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6161
func applicationWillTerminate(_ application: UIApplication) {
6262
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
6363
}
64+
65+
// PusherDelegate functions
66+
67+
func subscribedToInterest(name: String) {
68+
print("Subscribed to interest: \(name)")
69+
}
70+
71+
func registeredForPushNotifications(clientId: String) {
72+
print("Registered with Pusher for push notifications with clientId: \(clientId)")
73+
74+
}
6475
}

iOS Example Swift/iOS Example Swift/ViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import UIKit
1010
import PusherSwift
1111

12-
class ViewController: UIViewController, PusherConnectionDelegate {
12+
class ViewController: UIViewController, PusherDelegate {
1313
var pusher: Pusher! = nil
1414

1515
@IBAction func connectButton(_ sender: AnyObject) {
@@ -25,10 +25,10 @@ class ViewController: UIViewController, PusherConnectionDelegate {
2525

2626
// Only use your secret here for testing or if you're sure that there's
2727
// no security risk
28-
let pusherClientOptions = PusherClientOptions(authMethod: .inline(secret: "YOUR_APP_SECRET"))
29-
pusher = Pusher(key: "YOUR_APP_KEY", options: pusherClientOptions)
28+
let pusherClientOptions = PusherClientOptions(authMethod: .inline(secret: "daef58559fdd0aba8b63"))
29+
pusher = Pusher(key: "568d5a3851502158a022", options: pusherClientOptions)
3030

31-
pusher.connection.delegate = self
31+
pusher.delegate = self
3232

3333
pusher.connect()
3434

@@ -61,15 +61,15 @@ class ViewController: UIViewController, PusherConnectionDelegate {
6161
chan.trigger(eventName: "client-test", data: ["test": "some value"])
6262
}
6363

64-
// PusherConnectionDelegate methods
64+
// PusherDelegate methods
6565

66-
func connectionStateDidChange(from old: ConnectionState, to new: ConnectionState) {
66+
func changedConnectionState(from old: ConnectionState, to new: ConnectionState) {
6767
// print the old and new connection states
6868
print("old: \(old.stringValue()) -> new: \(new.stringValue())")
6969
}
7070

71-
func subscriptionDidSucceed(channelName: String) {
72-
print("Subscribed to \(channelName)")
71+
func subscribedToChannel(name: String) {
72+
print("Subscribed to \(name)")
7373
}
7474

7575
func debugLog(message: String) {

0 commit comments

Comments
 (0)