Skip to content

Commit 87da1ee

Browse files
committed
add callback to setHost
1 parent dc443dd commit 87da1ee

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

Docs/API.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -821,20 +821,21 @@ const pushPayload = {
821821
```
822822
---
823823
824-
##### <a id="setHost"> **`setHost(hostPrefix, hostName)`**
824+
##### <a id="setHost"> **`setHost(hostPrefix, hostName, successC)`**
825825
826826
Set a custom host
827827
828828
| parameter | type | description |
829829
| ----------|----------|------------------|
830830
| hostPrefix | string | the host prefix |
831831
| hostName | string | the host name |
832+
| successC | function | success callback |
832833
833834
834835
*Example:*
835836
836837
```javascript
837-
appsFlyer.setHost('foo', 'bar.appsflyer.com');
838+
appsFlyer.setHost('foo', 'bar.appsflyer.com', res => console.log(res));
838839
```
839840
---
840841
@@ -853,5 +854,5 @@ for more information: https://support.appsflyer.com/hc/en-us/articles/207032126-
853854
*Example:*
854855
855856
```javascript
856-
appsFlyer.addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"]);
857+
appsFlyer.addPushNotificationDeepLinkPath(["deeply", "nested", "deep_link"], res => console.log(res), error => console.log(error));
857858
```

android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,9 @@ public void sendPushNotificationData(ReadableMap pushPayload) {
679679
}
680680

681681
@ReactMethod
682-
public void setHost(String hostPrefix, String hostName) {
682+
public void setHost(String hostPrefix, String hostName, Callback successCallback) {
683683
AppsFlyerLib.getInstance().setHost(hostPrefix, hostName);
684+
successCallback.invoke(SUCCESS);
684685
}
685686

686687
@ReactMethod

index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ declare module "react-native-appsflyer" {
8888
validateAndLogInAppPurchase(purchaseInfo: InAppPurchase, successC, errorC): Response<string>
8989
updateServerUninstallToken(token: string, successC?: SuccessCB): void
9090
sendPushNotificationData(pushPayload: object): void
91-
setHost(hostPrefix: string, hostName: string, success?: SuccessCB): void
91+
setHost(hostPrefix: string, hostName: string, success: SuccessCB): void
9292
addPushNotificationDeepLinkPath(path: string[], successC: SuccessCB, errorC: ErrorCB): void
9393

9494
/**

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,10 @@ appsFlyer.sendPushNotificationData = (pushPayload) => {
531531
* Set a custom host
532532
* @param hostPrefix
533533
* @param hostName
534+
* @param successC: success callback
534535
*/
535-
appsFlyer.setHost = (hostPrefix, hostName) => {
536-
RNAppsFlyer.setHost(hostPrefix, hostName);
536+
appsFlyer.setHost = (hostPrefix, hostName, successC) => {
537+
RNAppsFlyer.setHost(hostPrefix, hostName, successC);
537538
}
538539

539540
/**

ios/RNAppsFlyer.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,9 @@ -(void) reportOnSuccess:(NSString *)data type:(NSString*) type {
526526
[[AppsFlyerLib shared] handlePushNotification:pushPayload];
527527
}
528528

529-
RCT_EXPORT_METHOD(setHost: (NSString*)hostPrefix hostName: (NSString*)hostName) {
529+
RCT_EXPORT_METHOD(setHost: (NSString*)hostPrefix hostName: (NSString*)hostName successCallback :(RCTResponseSenderBlock)successCallback) {
530530
[[AppsFlyerLib shared] setHost:hostName withHostPrefix:hostPrefix];
531+
successCallback(@[SUCCESS]);
531532
}
532533

533534
RCT_EXPORT_METHOD(addPushNotificationDeepLinkPath: (NSArray*)path successCallback :(RCTResponseSenderBlock)successCallback

0 commit comments

Comments
 (0)