Skip to content

Commit 25c8f3e

Browse files
committed
Add more to example iOS app and change build settings to include
the PusherSwift-iOS framework as opposed to the pod install framework.
1 parent 25e5692 commit 25c8f3e

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Example/ViewController.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,48 @@ class ViewController: UIViewController, ConnectionStateChangeDelegate {
1414
override func viewDidLoad() {
1515
super.viewDidLoad()
1616

17+
// remove the debugLogger from the client options if you want to remove the
18+
// debug logging, or just change the function below
19+
let debugLogger = { (text: String) in debugPrint(text) }
20+
1721
// Only use your secret here for testing or if you're sure that there's
1822
// no security risk
19-
let pusher = Pusher(key: "YOUR_APP_KEY", options: ["secret": "YOUR_APP_SECRET"])
23+
let pusher = Pusher(key: "YOUR_APP_KEY", options: ["secret": "YOUR_APP_SECRET", "debugLogger": debugLogger])
2024

2125
pusher.connection.stateChangeDelegate = self
2226
pusher.connect()
2327

28+
pusher.bind({ (message: AnyObject?) in
29+
if let message = message as? [String: AnyObject], eventName = message["event"] as? String where eventName == "pusher:error" {
30+
if let data = message["data"] as? [String: AnyObject], errorMessage = data["message"] as? String {
31+
print("Error message: \(errorMessage)")
32+
}
33+
}
34+
})
35+
2436
let onMemberAdded = { (member: PresenceChannelMember) in
2537
print(member)
2638
}
39+
2740
let chan = pusher.subscribe("presence-channel", onMemberAdded: onMemberAdded)
2841

2942
chan.bind("test-event", callback: { (data: AnyObject?) -> Void in
3043
print(data)
44+
pusher.subscribe("presence-channel", onMemberAdded: onMemberAdded)
45+
3146
if let data = data as? Dictionary<String, AnyObject> {
3247
if let testVal = data["test"] as? String {
3348
print(testVal)
3449
}
3550
}
3651
})
3752

53+
// triggers a client event
3854
chan.trigger("client-test", data: ["test": "some value"])
3955
}
4056

4157
func connectionChange(old: ConnectionState, new: ConnectionState) {
58+
// print the old and new connection states
4259
print("old: \(old) -> new: \(new)")
4360
}
4461
}

iOS Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
33831CC31A9CFCDB00B124F1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33831CBF1A9CFCDB00B124F1 /* Images.xcassets */; };
1212
33831CC41A9CFCDB00B124F1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 33831CC01A9CFCDB00B124F1 /* Main.storyboard */; };
1313
33831CC51A9CFCDB00B124F1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33831CC11A9CFCDB00B124F1 /* ViewController.swift */; };
14-
E3215575E0FEAFCC656457D2 /* Pods_iOS_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21AFCABFD6461F6288FAA7A5 /* Pods_iOS_Example.framework */; };
14+
339CCE801D10226600E921A5 /* PusherSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33E0ADA11B4BF5110060B7F5 /* PusherSwift.framework */; };
1515
/* End PBXBuildFile section */
1616

1717
/* Begin PBXContainerItemProxy section */
@@ -77,7 +77,7 @@
7777
isa = PBXFrameworksBuildPhase;
7878
buildActionMask = 2147483647;
7979
files = (
80-
E3215575E0FEAFCC656457D2 /* Pods_iOS_Example.framework in Frameworks */,
80+
339CCE801D10226600E921A5 /* PusherSwift.framework in Frameworks */,
8181
);
8282
runOnlyForDeploymentPostprocessing = 0;
8383
};

0 commit comments

Comments
 (0)