Skip to content

Allow JS init with param app Id #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 14, 2020
Merged
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import ZendeskChat from "react-native-zendesk-chat";

// Once in your application:
ZendeskChat.init("YOUR_ZENDESK_ACCOUNT_KEY");

// Optionally specify the appId provided by Zendesk
ZendeskChat.init("YOUR_ZENDESK_ACCOUNT_KEY", "APP_ID_PROVIDED_BY_ZENDESK");
```

3. Show the Chat UI
Expand Down
2 changes: 1 addition & 1 deletion RNZendeskChat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ declare module "react-native-zendesk-chat" {
* Must be called before calling startChat/setVisitorInfo
* - (Advanced users may configure this natively instead of calling this from JS)
*/
init: (zendeskAccountKey: string) => void;
init: (zendeskAccountKey: string, appId?: string) => void;

/**
* Presents the Zendesk Chat User Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ public void setVisitorInfo(ReadableMap options) {
}

@ReactMethod
public void init(String key) {
Chat.INSTANCE.init(mReactContext, key);
public void init(String key, String appId) {
if (appId != null) {
Chat.INSTANCE.init(mReactContext, key, appId);
} else {
Chat.INSTANCE.init(mReactContext, key);
}
Log.d(TAG, "Chat.INSTANCE was properly initialized from JS.");
}

Expand Down
8 changes: 6 additions & 2 deletions ios/RNZendeskChatModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ - (void) dismissChatUI {
[RCTPresentedViewController() dismissViewControllerAnimated:YES completion:nil];
}

RCT_EXPORT_METHOD(init:(NSString *)zenDeskKey) {
[ZDKChat initializeWithAccountKey:zenDeskKey queue:dispatch_get_main_queue()];
RCT_EXPORT_METHOD(init:(NSString *)zenDeskKey appId:(NSString *)appId) {
if (appId) {
[ZDKChat initializeWithAccountKey:zenDeskKey appId:appId queue:dispatch_get_main_queue()];
} else {
[ZDKChat initializeWithAccountKey:zenDeskKey queue:dispatch_get_main_queue()];
}
}

@end