Skip to content

Commit

Permalink
Fix missing token bug for App Events
Browse files Browse the repository at this point in the history
  • Loading branch information
ptxmac committed Mar 1, 2021
1 parent 0546204 commit f8b34a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

- App Events use the correct token if none have been provided manually

### Important

[Full Changelog](https://github.com/facebook/facebook-ios-sdk/compare/v9.1.0...HEAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ + (NSString *)tokenStringToUseFor:(FBSDKAccessToken *)token
// If there's an logging override app id present, then we don't want to use the client token since the client token
// is intended to match up with the primary app id (and AppEvents doesn't require a client token).
NSString *clientTokenString = [FBSDKSettings clientToken];
if (clientTokenString && appID && [appID isEqualToString:token.appID]) {
if (clientTokenString && appID && ([appID isEqualToString:token.appID] || token == nil)) {
tokenString = [NSString stringWithFormat:@"%@|%@", appID, clientTokenString];
} else if (appID) {
tokenString = nil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,13 @@ - (void)testGetStandardEvents
}
}

- (void)testProvideTokenForAppAndClient
{
[FBSDKAppEvents setLoggingOverrideAppID:nil];
[FBSDKSettings setAppID:@"123"];
[FBSDKSettings setClientToken:@"toktok"];
NSString *token = [FBSDKAppEventsUtility tokenStringToUseFor:nil];
XCTAssertEqualObjects(@"123|toktok", token);
}

@end

0 comments on commit f8b34a3

Please sign in to comment.