Skip to content

Commit 56c5744

Browse files
author
Swasti Gupta
committed
Corrected account retrival methods
1 parent e26dafb commit 56c5744

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

docs/MSAL_2x_Migration_Guide.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Add the following entry to your app’s Info.plist:
4444
<dict>
4545
<key>CFBundleURLSchemes</key>
4646
<array>
47-
<string>msauth.com.yourcompany.yourapp</string>
47+
<string>msauth.your.bundle.id</string>
4848
</array>
4949
</dict>
5050
</array>
@@ -374,7 +374,7 @@ application.acquireToken(with: parameters) { (result, error) in
374374

375375
**Use Instead:**
376376
- `accountForIdentifier:error:`
377-
- Use other synchronous or asynchronous account retrieval APIs like `accountsFromDeviceWithCompletionBlock:` depending on your scenario
377+
- Use other synchronous account retrieval APIs like `accountsForParameters:error:` depending on your scenario
378378

379379
Objective-C – Before (Deprecated):
380380
```objc
@@ -395,11 +395,18 @@ NSError *error = nil;
395395
MSALAccount *account = [application accountForIdentifier:@"accountId"
396396
error:&error];
397397
398-
// Recommended modern asynchronous way to fetch accounts
399-
[application accountsFromDeviceWithCompletionBlock:^(NSArray<MSALAccount *> *accounts, NSError *error)
400-
{
398+
// Recommended synchronous way to fetch accounts
399+
MSALAccountEnumerationParameters *parameters = [[MSALAccountEnumerationParameters alloc] initWithIdentifier:identifier];
400+
NSArray<MSALAccount *> *accounts = [application accountsForParameters:parameters
401+
error:&error];
402+
if (error)
403+
{
404+
NSLog(@"Failed to retrieve accounts: %@", error.localizedDescription);
405+
}
406+
else
407+
{
401408
// Handle accounts
402-
}];
409+
}
403410
```
404411

405412
Swift – Before (Deprecated):
@@ -411,8 +418,13 @@ do {
411418
print("Failed to get account: \(error)")
412419
}
413420

414-
application.allAccountsFilteredByAuthority { (accounts, error) in
415-
// Handle accounts
421+
let parameters = MSALAccountEnumerationParameters(identifier: identifier)
422+
423+
do {
424+
let accounts = try application.accounts(for: parameters)
425+
// Handle account
426+
} catch {
427+
print("Failed to retrieve accounts: \(error)")
416428
}
417429
```
418430

0 commit comments

Comments
 (0)