[links] Tweak links event name

This commit is contained in:
Chris Bianca 2018-03-22 14:56:15 +00:00
parent 2891027f25
commit 4173318379
2 changed files with 13 additions and 15 deletions

View File

@ -36,9 +36,6 @@ static NSString *const STORAGE_DOWNLOAD_FAILURE = @"download_failure";
static NSString *const MESSAGING_MESSAGE_RECEIVED = @"messaging_message_received";
static NSString *const MESSAGING_TOKEN_REFRESHED = @"messaging_token_refreshed";
// TODO: Remove
static NSString *const MESSAGING_NOTIFICATION_RECEIVED = @"messaging_notification_received";
// Notifications
static NSString *const NOTIFICATIONS_NOTIFICATION_DISPLAYED = @"notifications_notification_displayed";
static NSString *const NOTIFICATIONS_NOTIFICATION_OPENED = @"notifications_notification_opened";
@ -49,6 +46,9 @@ static NSString *const ADMOB_INTERSTITIAL_EVENT = @"interstitial_event";
static NSString *const ADMOB_REWARDED_VIDEO_EVENT = @"rewarded_video_event";
// Links
static NSString *const LINKS_DYNAMIC_LINK_RECEIVED = @"links_link_received";
static NSString *const LINKS_LINK_RECEIVED = @"links_link_received";
// Invites
static NSString *const INVITES_INVITATION_RECEIVED = @"invites_invitation_received";
#endif

View File

@ -7,7 +7,7 @@
static void sendDynamicLink(NSURL *url, id sender) {
if (url) {
[[NSNotificationCenter defaultCenter] postNotificationName:LINKS_DYNAMIC_LINK_RECEIVED
[[NSNotificationCenter defaultCenter] postNotificationName:LINKS_LINK_RECEIVED
object:sender
userInfo:@{@"url": url.absoluteString}];
NSLog(@"sendDynamicLink Success: %@", url.absoluteString);
@ -31,7 +31,7 @@ RCT_EXPORT_MODULE();
// Set up internal listener to send notification over bridge
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sendDynamicLinkEvent:)
name:LINKS_DYNAMIC_LINK_RECEIVED
name:LINKS_LINK_RECEIVED
object:nil];
}
@ -83,11 +83,11 @@ continueUserActivity:(NSUserActivity *)userActivity
}
- (NSArray<NSString *> *)supportedEvents {
return @[LINKS_DYNAMIC_LINK_RECEIVED];
return @[LINKS_LINK_RECEIVED];
}
- (void)sendDynamicLinkEvent:(NSNotification *)notification {
[self sendEventWithName:LINKS_DYNAMIC_LINK_RECEIVED body:notification.userInfo[@"url"]];
[self sendEventWithName:LINKS_LINK_RECEIVED body:notification.userInfo[@"url"]];
}
-(void)handleInitialLinkFromCustomSchemeURL:(NSURL*)url resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
@ -126,7 +126,7 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) {
NSURL* url = (NSURL*)self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
[self handleInitialLinkFromCustomSchemeURL:url resolver:resolve rejecter:reject];
} else {
NSDictionary *userActivityDictionary =
self.bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
@ -137,7 +137,7 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
RCT_EXPORT_METHOD(createDynamicLink: (NSDictionary *) metadata resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
@try {
FIRDynamicLinkComponents *components = [self getDynamicLinkComponentsFromMetadata:metadata];
if (components == nil) {
reject(@"links/failure", @"Failed to create Dynamic Link", nil);
} else {
@ -181,11 +181,11 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
NSURL *link = [NSURL URLWithString:metadata[@"link"]];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domain:metadata[@"dynamicLinkDomain"]];
[self setAndroidParameters:metadata components:components];
[self setIosParameters:metadata components:components];
[self setSocialMetaTagParameters:metadata components:components];
return components;
}
@catch(NSException * e) {
@ -200,7 +200,7 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
if (androidParametersDict) {
FIRDynamicLinkAndroidParameters *androidParams = [FIRDynamicLinkAndroidParameters
parametersWithPackageName: androidParametersDict[@"androidPackageName"]];
if (androidParametersDict[@"androidFallbackLink"]) {
androidParams.fallbackURL = [NSURL URLWithString:androidParametersDict[@"androidFallbackLink"]];
}
@ -283,5 +283,3 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
@implementation RNFirebaseLinks
@end
#endif