Skip to content

Commit

Permalink
feat: add setClientToken method (#428)
Browse files Browse the repository at this point in the history
* Add functions to edit client token inapp

* Put back imports

* Fix function name

* style(lint): `yarn validate:prettier --write`

fixes tiny spacing issue

---------

Co-authored-by: Mike Hardy <[email protected]>
  • Loading branch information
martinfrouin and mikehardy authored Aug 18, 2023
1 parent 3ae98c6 commit 791bfda
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public static void setAppID(String appID) {
FacebookSdk.setApplicationId(appID);
}

/**
* Set client token
* @param clientToken client token
*/
@ReactMethod
public static void setClientToken(String clientToken) {
FacebookSdk.setClientToken(clientToken);
}

@ReactMethod
public static void setAppName(String displayName) {
FacebookSdk.setApplicationName(displayName);
Expand Down
5 changes: 5 additions & 0 deletions ios/RCTFBSDK/core/RCTFBSDKSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ - (dispatch_queue_t)methodQueue
[FBSDKSettings.sharedSettings setAppID:appID];
}

RCT_EXPORT_METHOD(setClientToken:(NSString *)clientToken)
{
[FBSDKSettings.sharedSettings setClientToken:clientToken];
}

RCT_EXPORT_METHOD(setAppName:(NSString *)displayName)
{
[FBSDKSettings.sharedSettings setDisplayName:displayName];
Expand Down
15 changes: 15 additions & 0 deletions src/FBSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ export default {
}
Settings.setAppID(appID);
},
/**
* Set clientToken
*/
setClientToken(clientToken: string) {
if (
!isDefined(clientToken) ||
!isString(clientToken) ||
clientToken.length === 0
) {
throw new Error(
"setClientToken expected 'clientToken' to be a non empty string",
);
}
Settings.setClientToken(clientToken);
},
/**
* Sets the Facebook application name for the current app.
*/
Expand Down

0 comments on commit 791bfda

Please sign in to comment.