remove analytics treatment in creation and add some logs

This commit is contained in:
Omer Levy 2017-09-28 06:20:29 -04:00
parent 559b4f1329
commit df6b2ac4cc
2 changed files with 4 additions and 60 deletions

View File

@ -2,7 +2,6 @@
#define RNFirebaseLinks_h #define RNFirebaseLinks_h
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#if __has_include(<FirebaseDynamicLinks/FIRDynamicLinks.h>) #if __has_include(<FirebaseDynamicLinks/FIRDynamicLinks.h>)
#import <React/RCTBridgeModule.h> #import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h> #import <React/RCTEventEmitter.h>

View File

@ -9,15 +9,13 @@ static void sendDynamicLink(NSURL *url, id sender) {
[[NSNotificationCenter defaultCenter] postNotificationName:LINKS_DYNAMIC_LINK_RECEIVED [[NSNotificationCenter defaultCenter] postNotificationName:LINKS_DYNAMIC_LINK_RECEIVED
object:sender object:sender
userInfo:@{@"url": url.absoluteString}]; userInfo:@{@"url": url.absoluteString}];
NSLog(@"sendDynamicLinkSuccess: %@", url.absoluteString);
} }
@implementation RNFirebaseLinks @implementation RNFirebaseLinks
RCT_EXPORT_MODULE(); RCT_EXPORT_MODULE();
- (id)init { - (id)init {
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
@ -85,6 +83,7 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
} }
} }
NSString* initialLinkString = initialLink ? initialLink.absoluteString : (id)kCFNull; NSString* initialLinkString = initialLink ? initialLink.absoluteString : (id)kCFNull;
NSLog(@"getInitialLink: link is: %@", initialLinkString);
resolve(initialLinkString); resolve(initialLinkString);
} }
@ -95,7 +94,7 @@ RCT_EXPORT_METHOD(createDynamicLink: (NSDictionary *) metadata resolver:(RCTProm
reject(@"links/failure", @"error", nil); reject(@"links/failure", @"error", nil);
} else { } else {
NSURL *longLink = components.url; NSURL *longLink = components.url;
NSLog(@"Long URL: %@", longLink.absoluteString); NSLog(@"created long dynamic link: %@", longLink.absoluteString);
resolve(longLink.absoluteString); resolve(longLink.absoluteString);
} }
} }
@ -111,12 +110,11 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
reject(@"links/failure", error.description, nil); reject(@"links/failure", error.description, nil);
} }
NSURL *shortLink = shortURL; NSURL *shortLink = shortURL;
NSLog(@"Short URL: %@", shortLink.absoluteString); NSLog(@"created short dynamic link: %@", shortLink.absoluteString);
resolve(shortLink.absoluteString); resolve(shortLink.absoluteString);
}]; }];
} }
- (FIRDynamicLinkComponents *)getDynamicLinkComponentsFromMetadata:(NSDictionary *)metadata { - (FIRDynamicLinkComponents *)getDynamicLinkComponentsFromMetadata:(NSDictionary *)metadata {
NSURL *link = [NSURL URLWithString:metadata[@"link"]]; NSURL *link = [NSURL URLWithString:metadata[@"link"]];
FIRDynamicLinkComponents *components = FIRDynamicLinkComponents *components =
@ -124,7 +122,6 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
[self setAndroidParameters:metadata components:components]; [self setAndroidParameters:metadata components:components];
[self setIosParameters:metadata components:components]; [self setIosParameters:metadata components:components];
[self setSocialMetaTagParameters:metadata components:components]; [self setSocialMetaTagParameters:metadata components:components];
[self setAnalyticsParameters:metadata components:components];
[self setSuffixParameters:metadata components:components]; [self setSuffixParameters:metadata components:components];
return components; return components;
} }
@ -191,57 +188,6 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
} }
} }
- (void)setAnalyticsParameters:(NSDictionary *)metadata
components:(FIRDynamicLinkComponents *)components {
NSDictionary *analyticsParametersDict = metadata[@"analyticsInfo"];
if (analyticsParametersDict) {
[self setGoogleAnalyticsParameters:metadata components:components];
[self setItunesConnectAnalyticsParameters:metadata components:components];
}
}
- (void)setGoogleAnalyticsParameters:(NSDictionary *)metadata
components:(FIRDynamicLinkComponents *)components {
NSDictionary *analyticsParametersDict = metadata[@"googlePlayAnalytics"];
if (analyticsParametersDict) {
FIRDynamicLinkGoogleAnalyticsParameters *analyticsParams = [FIRDynamicLinkGoogleAnalyticsParameters parameters];
if (analyticsParametersDict[@"utmSource"]) {
analyticsParams.source = analyticsParametersDict[@"utmSource"];
}
if (analyticsParametersDict[@"utmMedium"]) {
analyticsParams.medium = analyticsParametersDict[@"utmMedium"];
}
if (analyticsParametersDict[@"utmCampaign"]) {
analyticsParams.campaign = analyticsParametersDict[@"utmCampaign"];
}
if (analyticsParametersDict[@"utmTerm"]) {
analyticsParams.term = analyticsParametersDict[@"utmTerm"];
}
if (analyticsParametersDict[@"utmContent"]) {
analyticsParams.content = analyticsParametersDict[@"utmContent"];
}
components.analyticsParameters = analyticsParams;
}
}
- (void)setItunesConnectAnalyticsParameters:(NSDictionary *)metadata
components:(FIRDynamicLinkComponents *)components {
NSDictionary *appStoreParametersDict = metadata[@"itunesConnectAnalytics"];
if (appStoreParametersDict) {
FIRDynamicLinkItunesConnectAnalyticsParameters *appStoreParams = [FIRDynamicLinkItunesConnectAnalyticsParameters parameters];
if (appStoreParametersDict[@"at"]) {
appStoreParams.affiliateToken = appStoreParametersDict[@"at"];
}
if (appStoreParametersDict[@"ct"]) {
appStoreParams.campaignToken = appStoreParametersDict[@"ct"];
}
if (appStoreParametersDict[@"pt"]) {
appStoreParams.providerToken = appStoreParametersDict[@"pt"];
}
components.iTunesConnectParameters = appStoreParams;
}
}
- (void)setSuffixParameters:(NSDictionary *)metadata - (void)setSuffixParameters:(NSDictionary *)metadata
components:(FIRDynamicLinkComponents *)components { components:(FIRDynamicLinkComponents *)components {
NSDictionary *suffixParametersDict = metadata[@"suffix"]; NSDictionary *suffixParametersDict = metadata[@"suffix"];
@ -257,7 +203,6 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
} }
} }
@end @end
#else #else