@@ -76,14 +76,6 @@ -(void)reset;
7676 ARTRest *const rest = [[ARTRest alloc ] initWithOptions: options.clientOptions];
7777 [instanceStore setRest: rest with: handle];
7878
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-
8779 result (handle);
8880};
8981
@@ -262,19 +254,6 @@ -(void)reset;
262254 }
263255 ARTRealtime *const realtime = [[ARTRealtime alloc ] initWithOptions: options.clientOptions];
264256 [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- }
278257
279258 result (handle);
280259};
@@ -801,7 +780,6 @@ -(void)reset {
801780}
802781
803782- (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
804- [[UIApplication sharedApplication ] registerForRemoteNotifications ];
805783 // Check if application was launched from a notification tap.
806784
807785 // https://stackoverflow.com/a/21611009/7365866
@@ -814,16 +792,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
814792}
815793
816794#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+
818796-(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.
820797 [_instanceStore didRegisterForRemoteNotificationsWithDeviceToken: deviceToken];
821798}
822799
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.
824800- (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];
827802}
828803
829804- (BOOL )application : (UIApplication *)application didReceiveRemoteNotification : (NSDictionary *)userInfo fetchCompletionHandler : (void (^)(UIBackgroundFetchResult))completionHandler {
0 commit comments