Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ - (void)initializePlatform
}
}



- (void)createNotificationRegistrationWithToken:(NSString* _Nonnull)deviceToken
{
_notificationRegistration = [[MCDConnectedDevicesNotificationRegistration alloc] init];
_notificationRegistration.type = MCDNotificationTypeAPN;
_notificationRegistration.appId = [[NSBundle mainBundle] bundleIdentifier];
_notificationRegistration.appDisplayName = (NSString*)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
_notificationRegistration.token = deviceToken;
NSLog(@"GraphNotifications Successfully created notification registration!");
NSLog(@"platformManager info %@", _platformManager);
[_platformManager setNotificationRegistration: _notificationRegistration];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
Expand Down Expand Up @@ -146,7 +132,7 @@ - (void)application:(__unused UIApplication*)application didRegisterForRemoteNot

@try
{
[self createNotificationRegistrationWithToken:deviceTokenStr];
[_platformManager setNotificationRegistration: deviceTokenStr];
}
@catch (NSException* exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef NS_ENUM(NSInteger, AccountRegistrationState) {
- (AnyPromise*)signInMsaAsync;
- (AnyPromise*)signOutAsync:(Account*)account;
- (NSMutableArray<Account*>*)deserializeAccounts;
- (void)setNotificationRegistration:(MCDConnectedDevicesNotificationRegistration*)registration;
- (void)setNotificationRegistration:(NSString*)deviceToken;
@end

#endif /* ConnectedDevicesPlatformManager_h */
Original file line number Diff line number Diff line change
Expand Up @@ -444,32 +444,32 @@ - (AnyPromise*)signOutAsync:(Account*)account {
});
}

- (void)setNotificationRegistration:(NSString*)tokenString {
- (void)setNotificationRegistration:(NSString*)deviceToken {
MCDConnectedDevicesNotificationRegistration* notificationRegistration = [[MCDConnectedDevicesNotificationRegistration alloc] init];
notificationRegistration.type = MCDNotificationTypeAPN;
notificationRegistration.appId = [[NSBundle mainBundle] bundleIdentifier];
notificationRegistration.appDisplayName = (NSString*)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
notificationRegistration.token = deviceToken;

MCDConnectedDevicesNotificationRegistration* registration = [MCDConnectedDevicesNotificationRegistration new];
NSLog(@"GraphNotifications Successfully created notification registration!");

if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications])
{
registration.type = MCDNotificationTypeAPN;
notificationRegistration.type = MCDNotificationTypeAPN;
}
else
{
registration.type = MCDNotificationTypePolling;
notificationRegistration.type = MCDNotificationTypePolling;
}

registration.appId = [[NSBundle mainBundle] bundleIdentifier];
registration.appDisplayName = (NSString*)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
registration.token = tokenString;

// The two cases of receiving a new notification token are:
// 1. A notification registration is asked for and now it is available. In this case there is a pending promise that was made
// at the time of requesting the information. It now needs completed.
// 2. The account is already registered but for whatever reason the registration changes (APNS gives the app a new token)
//
// In order to most cleany handle both cases set the new notification information and then trigger a re registration of all accounts
// that are in good standing.
[self.apnsManager setNotificationRegistration:registration accounts:self.accounts];
[self.apnsManager setNotificationRegistration:notificationRegistration accounts:self.accounts];
}


@end