@@ -76,14 +76,6 @@ -(void)reset;
76
76
ARTRest *const rest = [[ARTRest alloc ] initWithOptions: options.clientOptions];
77
77
[instanceStore setRest: rest with: handle];
78
78
79
- NSData *const apnsDeviceToken = ably.instanceStore .didRegisterForRemoteNotificationsWithDeviceToken_deviceToken ;
80
- NSError *const error = ably.instanceStore .didFailToRegisterForRemoteNotificationsWithError_error ;
81
- if (apnsDeviceToken != nil ) {
82
- [ARTPush didRegisterForRemoteNotificationsWithDeviceToken: apnsDeviceToken rest: rest];
83
- } else if (error != nil ) {
84
- [ARTPush didFailToRegisterForRemoteNotificationsWithError: error rest: rest];
85
- }
86
-
87
79
result (handle);
88
80
};
89
81
@@ -262,19 +254,6 @@ -(void)reset;
262
254
}
263
255
ARTRealtime *const realtime = [[ARTRealtime alloc ] initWithOptions: options.clientOptions];
264
256
[instanceStore setRealtime: realtime with: handle];
265
-
266
- // Giving Ably client the deviceToken registered at device launch (didRegisterForRemoteNotificationsWithDeviceToken).
267
- // This is not an ideal solution. We save the deviceToken given in didRegisterForRemoteNotificationsWithDeviceToken and the
268
- // error in didFailToRegisterForRemoteNotificationsWithError and pass it to Ably in the first client that is first created.
269
- // Ideally, the Ably client doesn't need to be created, and we can pass the deviceToken to Ably like in Ably Java.
270
- // This is similarly repeated for in _createRest
271
- NSData *const apnsDeviceToken = ably.instanceStore .didRegisterForRemoteNotificationsWithDeviceToken_deviceToken ;
272
- NSError *const error = ably.instanceStore .didFailToRegisterForRemoteNotificationsWithError_error ;
273
- if (apnsDeviceToken != nil ) {
274
- [ARTPush didRegisterForRemoteNotificationsWithDeviceToken: apnsDeviceToken realtime: realtime];
275
- } else if (error != nil ) {
276
- [ARTPush didFailToRegisterForRemoteNotificationsWithError: error realtime: realtime];
277
- }
278
257
279
258
result (handle);
280
259
};
@@ -801,7 +780,6 @@ -(void)reset {
801
780
}
802
781
803
782
- (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
804
- [[UIApplication sharedApplication ] registerForRemoteNotifications ];
805
783
// Check if application was launched from a notification tap.
806
784
807
785
// https://stackoverflow.com/a/21611009/7365866
@@ -814,16 +792,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
814
792
}
815
793
816
794
#pragma mark - Push Notifications Registration - UIApplicationDelegate
817
- // / Save the deviceToken provided so we can pass it to the first Ably client which gets created, in createRealtime or createRest.
795
+
818
796
-(void )application : (UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken {
819
- // Set deviceToken on all existing Ably clients, and a property which used for all future Ably clients.
820
797
[_instanceStore didRegisterForRemoteNotificationsWithDeviceToken: deviceToken];
821
798
}
822
799
823
- // / Save the error if it occurred during APNs device registration provided so we can pass it to the first Ably client which gets created, in createRealtime or createRest.
824
800
- (void )application : (UIApplication *)application didFailToRegisterForRemoteNotificationsWithError : (NSError *)error {
825
- // This error will be used when the first Ably client is made.
826
- _instanceStore.didFailToRegisterForRemoteNotificationsWithError_error = error;
801
+ [_instanceStore didFailToRegisterForRemoteNotificationsWithError: error];
827
802
}
828
803
829
804
- (BOOL )application : (UIApplication *)application didReceiveRemoteNotification : (NSDictionary *)userInfo fetchCompletionHandler : (void (^)(UIBackgroundFetchResult))completionHandler {
0 commit comments