Skip to content

Commit fe6563b

Browse files
authored
Merge pull request #100 from pusher/fix-task-queue-crash
Fix the task queue crash
2 parents 7714fed + 1947969 commit fe6563b

24 files changed

+956
-998
lines changed

PusherSwift/PusherSwift.xcodeproj/project.pbxproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
3389F5721CAEDDF300563F49 /* PusherChannels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3389F5711CAEDDF300563F49 /* PusherChannels.swift */; };
2020
3389F5761CAEDE2800563F49 /* PusherGlobalChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3389F5751CAEDE2800563F49 /* PusherGlobalChannel.swift */; };
2121
3389F57A1CAEDEC800563F49 /* PusherClientOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3389F5791CAEDEC800563F49 /* PusherClientOptions.swift */; };
22-
33A962741D88A9C900DA421E /* PusherConnectionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33A962731D88A9C800DA421E /* PusherConnectionDelegate.swift */; };
2322
33A962771D89483600DA421E /* PusherConnectionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33A962751D8943CA00DA421E /* PusherConnectionDelegateTests.swift */; };
2423
33BA541E1D90351B00CD853B /* NativePusherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BA541D1D90351B00CD853B /* NativePusherTests.swift */; };
2524
33BA54201D9035BD00CD853B /* PusherDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BA541F1D9035BD00CD853B /* PusherDelegate.swift */; };
@@ -66,7 +65,6 @@
6665
3389F5711CAEDDF300563F49 /* PusherChannels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherChannels.swift; sourceTree = "<group>"; };
6766
3389F5751CAEDE2800563F49 /* PusherGlobalChannel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherGlobalChannel.swift; sourceTree = "<group>"; };
6867
3389F5791CAEDEC800563F49 /* PusherClientOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherClientOptions.swift; sourceTree = "<group>"; };
69-
33A962731D88A9C800DA421E /* PusherConnectionDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherConnectionDelegate.swift; sourceTree = "<group>"; };
7068
33A962751D8943CA00DA421E /* PusherConnectionDelegateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PusherConnectionDelegateTests.swift; path = ../Tests/PusherConnectionDelegateTests.swift; sourceTree = "<group>"; };
7169
33BA541D1D90351B00CD853B /* NativePusherTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NativePusherTests.swift; path = ../Tests/NativePusherTests.swift; sourceTree = "<group>"; };
7270
33BA541F1D9035BD00CD853B /* PusherDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherDelegate.swift; sourceTree = "<group>"; };
@@ -130,7 +128,6 @@
130128
3389F5791CAEDEC800563F49 /* PusherClientOptions.swift */,
131129
33BA541F1D9035BD00CD853B /* PusherDelegate.swift */,
132130
3389F5651CAEDD5F00563F49 /* PusherConnection.swift */,
133-
33A962731D88A9C800DA421E /* PusherConnectionDelegate.swift */,
134131
3389F5691CAEDD9100563F49 /* PusherWebsocketDelegate.swift */,
135132
3384C1B81CAECD9C00F10796 /* PusherChannel.swift */,
136133
3389F56D1CAEDDD800563F49 /* PusherPresenceChannel.swift */,
@@ -260,7 +257,7 @@
260257
isa = PBXProject;
261258
attributes = {
262259
LastSwiftUpdateCheck = 0700;
263-
LastUpgradeCheck = 0800;
260+
LastUpgradeCheck = 0820;
264261
TargetAttributes = {
265262
33831C881A9CF61600B124F1 = {
266263
CreatedOnToolsVersion = 6.3;
@@ -332,7 +329,6 @@
332329
33BA54201D9035BD00CD853B /* PusherDelegate.swift in Sources */,
333330
3389F56A1CAEDD9100563F49 /* PusherWebsocketDelegate.swift in Sources */,
334331
330D7A6D1CAEDA750032FF2C /* PusherChannel.swift in Sources */,
335-
33A962741D88A9C900DA421E /* PusherConnectionDelegate.swift in Sources */,
336332
3389F5721CAEDDF300563F49 /* PusherChannels.swift in Sources */,
337333
3389F5761CAEDE2800563F49 /* PusherGlobalChannel.swift in Sources */,
338334
3389F57A1CAEDEC800563F49 /* PusherClientOptions.swift in Sources */,
@@ -449,7 +445,7 @@
449445
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
450446
CLANG_WARN_UNREACHABLE_CODE = YES;
451447
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
452-
CODE_SIGN_IDENTITY = "iPhone Developer";
448+
CODE_SIGN_IDENTITY = "";
453449
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
454450
COPY_PHASE_STRIP = NO;
455451
CURRENT_PROJECT_VERSION = 1;
@@ -512,7 +508,7 @@
512508
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
513509
CLANG_WARN_UNREACHABLE_CODE = YES;
514510
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
515-
CODE_SIGN_IDENTITY = "iPhone Developer";
511+
CODE_SIGN_IDENTITY = "";
516512
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
517513
COPY_PHASE_STRIP = NO;
518514
CURRENT_PROJECT_VERSION = 1;

PusherSwift/PusherSwift.xcodeproj/xcshareddata/xcschemes/PusherSwift.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0820"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

README.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -300,27 +300,27 @@ pusher.connection.userDataFetcher = ^PusherPresenceChannelMember* () {
300300
301301
### Connection delegate
302302
303-
There is a `PusherConnectionDelegate` that you can use to get access to connection-related information. These are the functions that you can optionally implement when conforming to the `PusherConnectionDelegate` protocol:
303+
There is a `PusherDelegate` that you can use to get notified of connection-related information. These are the functions that you can optionally implement when conforming to the `PusherDelegate` protocol:
304304
305305
```swift
306-
@objc optional func connectionStateDidChange(from old: ConnectionState, to new: ConnectionState)
306+
@objc optional func changedConnectionState(from old: ConnectionState, to new: ConnectionState)
307+
@objc optional func subscribedToChannel(name: String)
308+
@objc optional func failedToSubscribeToChannel(name: String, response: URLResponse?, data: String?, error: NSError?)
307309
@objc optional func debugLog(message: String)
308-
@objc optional func subscriptionDidSucceed(channelName: String)
309-
@objc optional func subscriptionDidFail(channelName: String, response: URLResponse?, data: String?, error: NSError?)
310310
```
311311

312312
The names of the functions largely give away what their purpose is but just for completeness:
313313

314-
- `connectionStateDidChange` - use this if you want to use connection state changes to perform different actions / UI updates
314+
- `changedConnectionState` - use this if you want to use connection state changes to perform different actions / UI updates
315+
- `subscribedToChannel` - use this if you want to be informed of when a channel has successfully been subscribed to, which is useful if you want to perform actions that are only relevant after a subscription has succeeded, e.g. logging out the members of a presence channel
316+
- `failedToSubscribeToChannel` - use this if you want to be informed of a failed subscription attempt, which you could use, for exampple, to then attempt another subscription or make a call to a service you use to track errors
315317
- `debugLog` - use this if you want to log Pusher-related events, e.g. the underlying websocket receiving a message
316-
- `subscriptionDidSucceed` - use this if you want to be informed of when a channel has successfully been subscribed to, which is useful if you want to perform actions that are only relevant after a subscription has succeeded, e.g. logging out the members of a presence channel
317-
- `subscriptionDidFail` - use this if you want to be informed of a failed subscription attempt, which you could use, for exampple, to then attempt another subscription or make a call to a service you use to track errors
318318

319319
Setting up a delegate looks like this:
320320

321321
#### Swift
322322
```swift
323-
class ViewController: UIViewController, PusherConnectionDelegate {
323+
class ViewController: UIViewController, PusherDelegate {
324324

325325
override func viewDidLoad() {
326326
super.viewDidLoad()
@@ -349,51 +349,51 @@ Here are examples of setting up a class with functions for each of the optional
349349
350350
#### Swift
351351
```swift
352-
class DummyDelegate: PusherConnectionDelegate {
353-
func connectionStateDidChange(from old: ConnectionState, to new: ConnectionState) {
352+
class DummyDelegate: PusherDelegate {
353+
func changedConnectionState(from old: ConnectionState, to new: ConnectionState) {
354354
// ...
355355
}
356356
357357
func debugLog(message: String) {
358358
// ...
359359
}
360360
361-
func subscriptionDidSucceed(channelName: String) {
361+
func subscribedToChannel(name: String) {
362362
// ...
363363
}
364364
365-
func subscriptionDidFail(channelName: String, response: URLResponse?, data: String?, error: NSError?) {
365+
func failedToSubscribeToChannel(name: String, response: URLResponse?, data: String?, error: NSError?) {
366366
// ...
367367
}
368368
}
369369
```
370370

371371
#### Objective-C
372372
```objc
373-
@interface DummyDelegate : NSObject <PusherConnectionDelegate>
373+
@interface DummyDelegate : NSObject <PusherDelegate>
374374

375-
- (void)connectionStateDidChangeFrom:(enum ConnectionState)old to:(enum ConnectionState)new_
375+
- (void)changedConnectionState:(enum ConnectionState)old to:(enum ConnectionState)new_
376376
- (void)debugLogWithMessage:(NSString *)message
377-
- (void)subscriptionDidSucceedWithChannelName:(NSString *)channelName
378-
- (void)subscriptionDidFailWithChannelName:(NSString *)channelName response:(NSURLResponse *)response data:(NSString *)data error:(NSError *)error
377+
- (void)subscribedToChannelWithName:(NSString *)name
378+
- (void)failedToSubscribeToChannelWithName:(NSString *)name response:(NSURLResponse *)response data:(NSString *)data error:(NSError *)error
379379

380380
@end
381381

382382
@implementation DummyDelegate
383383

384-
- (void)connectionStateDidChangeFrom:(enum ConnectionState)old to:(enum ConnectionState)new_ {
384+
- (void)changedConnectionState:(enum ConnectionState)old to:(enum ConnectionState)new_ {
385385
// ...
386386
}
387387

388388
- (void)debugLogWithMessage:(NSString *)message {
389389
// ...
390390
}
391391

392-
- (void)subscriptionDidSucceedWithChannelName:(NSString *)channelName {
392+
- (void)subscribedToChannelWithName:(NSString *)name {
393393
// ...
394394
}
395395

396-
- (void)subscriptionDidFailWithChannelName:(NSString *)channelName response:(NSURLResponse *)response data:(NSString *)data error:(NSError *)error {
396+
- (void)failedToSubscribeToChannelWithName:(NSString *)name response:(NSURLResponse *)response data:(NSString *)data error:(NSError *)error {
397397
// ...
398398
}
399399

@@ -546,14 +546,14 @@ PusherPresenceChannel *chan = [pusher subscribeToPresenceChannelWithChannelName:
546546
}];
547547
```
548548
549-
You can also be notified of a successfull subscription by using the `subscriptionDidSucceed` delegate method on the `PusherConnection` object.
549+
You can also be notified of a successfull subscription by using the `subscriptionDidSucceed` delegate method that is part of the `PusherDelegate` protocol.
550550
551-
Here is an example of using the connection delegate:
551+
Here is an example of using the delegate:
552552
553553
#### Swift
554554
```swift
555-
class DummyDelegate: PusherConnectionDelegate {
556-
func subscriptionDidSucceed(channelName: String) {
555+
class DummyDelegate: PusherDelegate {
556+
func subscribedToChannel(name: String) {
557557
if channelName == "presence-channel" {
558558
if let presChan = pusher.connection.channels.findPresence(channelName) {
559559
// in here you can now have access to the channel's members and myId properties
@@ -573,7 +573,7 @@ let chan = pusher.subscribeToPresenceChannel("presence-channel")
573573
```objc
574574
@implementation DummyDelegate
575575

576-
- (void)subscriptionDidSucceedWithChannelName:(NSString *)channelName {
576+
- (void)subscribedToChannelWithName:(NSString *)name {
577577
if ([channelName isEqual: @"presence-channel"]) {
578578
PusherPresenceChannel *presChan = [self.client.connection.channels findPresenceWithName:@"presence-channel"];
579579
NSLog(@"%@", [presChan members]);
@@ -813,8 +813,8 @@ Your app can now subscribe to interests. The following registers and subscribes
813813
#### Swift
814814
```swift
815815
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
816-
pusher.nativePusher().register(deviceToken: deviceToken)
817-
pusher.nativePusher().subscribe(interestName: "donuts")
816+
pusher.nativePusher.register(deviceToken: deviceToken)
817+
pusher.nativePusher.subscribe(interestName: "donuts")
818818
}
819819
```
820820

@@ -848,7 +848,7 @@ If at a later point you wish to unsubscribe from an interest, this works in the
848848

849849
#### Swift
850850
```swift
851-
pusher.nativePusher().unsubscribe(interestName: "donuts")
851+
pusher.nativePusher.unsubscribe(interestName: "donuts")
852852
```
853853

854854
#### Objective-C
@@ -861,19 +861,19 @@ For a complete example of a working app, see the [Example/](https://github.com/p
861861
862862
### Pusher delegate
863863
864-
There is a `PusherDelegate` that you can use to get access to events that occur in relation to push notifications interactions. These are the functions that you can optionally implement when conforming to the `PusherDelegate` protocol:
864+
You can also implement some of the `PusherDelegate` functions to get access to events that occur in relation to push notifications interactions. These are the functions that you can optionally implement when conforming to the `PusherDelegate` protocol:
865865
866866
```swift
867-
@objc optional func didRegisterForPushNotifications(clientId: String)
868-
@objc optional func didSubscribeToInterest(named name: String)
869-
@objc optional func didUnsubscribeFromInterest(named name: String)
867+
@objc optional func registeredForPushNotifications(clientId: String)
868+
@objc optional func subscribedToInterest(name: String)
869+
@objc optional func unsubscribedFromInterest(name: String)
870870
```
871871

872872
Again, the names of the functions largely give away what their purpose is but just for completeness:
873873

874-
- `didRegisterForPushNotifications` - use this if you want to know when a client has successfully registered with the Pusher Push Notifications service, or if you want access to the `clientId` that is returned upon successful registration
875-
- `didSubscribeToInterest` - use this if you want keep track of interests that are successfully subscribed to
876-
- `didUnsubscribeFromInterest` - use this if you want keep track of interests that are successfully unsubscribed from
874+
- `registeredForPushNotifications` - use this if you want to know when a client has successfully registered with the Pusher Push Notifications service, or if you want access to the `clientId` that is returned upon successful registration
875+
- `subscribedToInterest` - use this if you want keep track of interests that are successfully subscribed to
876+
- `unsubscribedFromInterest` - use this if you want keep track of interests that are successfully unsubscribed from
877877

878878
Setting up a delegate looks like this:
879879

@@ -904,7 +904,7 @@ class ViewController: UIViewController, PusherDelegate {
904904
}
905905
```
906906
907-
The process is identical to that of setting up a `PusherConnectionDelegate`. At some point in the future the `PusherDelegate` and `PusherConnectionDelegate` will likely be merged into the `PusherDelegate` in order to provide one unified delegate that can be used to get notified of Pusher-related events.
907+
The process is identical to that of setting up the `PusherDelegate` to receive notifications of connection-based events.
908908
909909
910910
## Testing

0 commit comments

Comments
 (0)