Skip to content
This repository was archived by the owner on Apr 2, 2021. It is now read-only.
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ import { AppEventsLogger } from "react-native-fbsdk";

// Log a $15 purchase.
AppEventsLogger.logPurchase(15, "USD", { param: "value" });

// Log a standart event.
AppEventsLogger.logEvent(AppEventsLogger.StandardEvents.CompletedRegistration);

// Log a custom event.
AppEventsLogger.logEvent('CustomEvent');
```

### [Graph API](https://developers.facebook.com/docs/graph-api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

import java.math.BigDecimal;
import java.util.Currency;
import java.util.HashMap;
import java.util.Map;

/**
* <p>
Expand Down Expand Up @@ -312,4 +314,35 @@ public void flush() {
public void setPushNotificationsRegistrationId(String registrationId) {
AppEventsLogger.setPushNotificationsRegistrationId(registrationId);
}

@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
final Map<String, Object> standardEvents = new HashMap<>();
standardEvents.put("AchievedLevel", AppEventsConstants.EVENT_NAME_ACHIEVED_LEVEL);
standardEvents.put("AdClick", AppEventsConstants.EVENT_NAME_AD_CLICK);
standardEvents.put("AdImpression", AppEventsConstants.EVENT_NAME_AD_IMPRESSION);
standardEvents.put("AddedPaymentInfo", AppEventsConstants.EVENT_NAME_ADDED_PAYMENT_INFO);
standardEvents.put("AddedToCart", AppEventsConstants.EVENT_NAME_ADDED_TO_CART);
standardEvents.put("AddedToWishlist", AppEventsConstants.EVENT_NAME_ADDED_TO_WISHLIST);
standardEvents.put("CompletedRegistration", AppEventsConstants.EVENT_NAME_COMPLETED_REGISTRATION);
standardEvents.put("CompletedTutorial", AppEventsConstants.EVENT_NAME_COMPLETED_TUTORIAL);
standardEvents.put("Contact", AppEventsConstants.EVENT_NAME_CONTACT);
standardEvents.put("CustomizeProduct", AppEventsConstants.EVENT_NAME_CUSTOMIZE_PRODUCT);
standardEvents.put("Donate", AppEventsConstants.EVENT_NAME_DONATE);
standardEvents.put("FindLocation", AppEventsConstants.EVENT_NAME_FIND_LOCATION);
standardEvents.put("InitiatedCheckout", AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT);
standardEvents.put("Purchased", AppEventsConstants.EVENT_NAME_PURCHASED);
standardEvents.put("Rated", AppEventsConstants.EVENT_NAME_RATED);
standardEvents.put("Searched", AppEventsConstants.EVENT_NAME_SEARCHED);
standardEvents.put("SpentCredits", AppEventsConstants.EVENT_NAME_SPENT_CREDITS);
standardEvents.put("Schedule", AppEventsConstants.EVENT_NAME_SCHEDULE);
standardEvents.put("StartTrial", AppEventsConstants.EVENT_NAME_START_TRIAL);
standardEvents.put("SubmitApplication", AppEventsConstants.EVENT_NAME_SUBMIT_APPLICATION);
standardEvents.put("Subscribe", AppEventsConstants.EVENT_NAME_SUBSCRIBE);
standardEvents.put("UnlockedAchievement", AppEventsConstants.EVENT_NAME_UNLOCKED_ACHIEVEMENT);
standardEvents.put("ViewedContent", AppEventsConstants.EVENT_NAME_VIEWED_CONTENT);
constants.put("StandardEvents", standardEvents);
return constants;
}
}
34 changes: 34 additions & 0 deletions ios/RCTFBSDK/core/RCTFBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,38 @@ - (dispatch_queue_t)methodQueue
return result;
}

- (NSDictionary *)constantsToExport {
return @{
@"StandardEvents": @{
@"AchievedLevel": FBSDKAppEventNameAchievedLevel,
@"AdClick": FBSDKAppEventNameAdClick,
@"AdImpression": FBSDKAppEventNameAdImpression,
@"AddedPaymentInfo": FBSDKAppEventNameAddedPaymentInfo,
@"AddedToCart": FBSDKAppEventNameAddedToCart,
@"AddedToWishlist": FBSDKAppEventNameAddedToWishlist,
@"CompletedRegistration": FBSDKAppEventNameCompletedRegistration,
@"CompletedTutorial": FBSDKAppEventNameCompletedTutorial,
@"Contact": FBSDKAppEventNameContact,
@"CustomizeProduct": FBSDKAppEventNameCustomizeProduct,
@"Donate": FBSDKAppEventNameDonate,
@"FindLocation": FBSDKAppEventNameFindLocation,
@"InitiatedCheckout": FBSDKAppEventNameInitiatedCheckout,
@"Purchased": FBSDKAppEventNamePurchased,
@"Rated": FBSDKAppEventNameRated,
@"Searched": FBSDKAppEventNameSearched,
@"SpentCredits": FBSDKAppEventNameSpentCredits,
@"Schedule": FBSDKAppEventNameSchedule,
@"StartTrial": FBSDKAppEventNameStartTrial,
@"SubmitApplication": FBSDKAppEventNameSubmitApplication,
@"Subscribe": FBSDKAppEventNameSubscribe,
@"UnlockedAchievement": FBSDKAppEventNameUnlockedAchievement,
@"ViewedContent": FBSDKAppEventNameViewedContent,
}
};
}

+ (BOOL)requiresMainQueueSetup {
return YES;
}

@end
2 changes: 2 additions & 0 deletions src/FBAppEventsLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,6 @@ module.exports = {
setPushNotificationsRegistrationId(registrationId: string) {
AppEventsLogger.setPushNotificationsRegistrationId(registrationId);
},

StandardEvents: AppEventsLogger.StandardEvents,
};