[invites][links] Fix some iOS specific issues
This commit is contained in:
parent
8e2d03cc5a
commit
72a1d1d439
@ -2,6 +2,7 @@
|
||||
|
||||
#if __has_include(<FirebaseInvites/FirebaseInvites.h>)
|
||||
#import "RNFirebaseEvents.h"
|
||||
#import "RNFirebaseLinks.h"
|
||||
#import "RNFirebaseUtil.h"
|
||||
#import <FirebaseInvites/FirebaseInvites.h>
|
||||
|
||||
@ -88,7 +89,7 @@ RCT_EXPORT_METHOD(getInitialInvitation:(RCTPromiseResolveBlock)resolve rejecter:
|
||||
url = userActivity.webpageURL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (url) {
|
||||
[FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
@ -121,7 +122,7 @@ RCT_EXPORT_METHOD(sendInvitation:(NSDictionary *) invitation
|
||||
[inviteDialog setInviteDelegate: self];
|
||||
[inviteDialog setMessage:invitation[@"message"]];
|
||||
[inviteDialog setTitle:invitation[@"title"]];
|
||||
|
||||
|
||||
if (invitation[@"androidClientId"]) {
|
||||
FIRInvitesTargetApplication *targetApplication = [[FIRInvitesTargetApplication alloc] init];
|
||||
targetApplication.androidClientID = invitation[@"androidClientId"];
|
||||
@ -139,11 +140,11 @@ RCT_EXPORT_METHOD(sendInvitation:(NSDictionary *) invitation
|
||||
if (invitation[@"deepLink"]) {
|
||||
[inviteDialog setDeepLink:invitation[@"deepLink"]];
|
||||
}
|
||||
|
||||
|
||||
// Save the promise details for later
|
||||
_invitationsRejecter = reject;
|
||||
_invitationsResolver = resolve;
|
||||
|
||||
|
||||
// Open the invitation dialog
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[inviteDialog open];
|
||||
@ -155,11 +156,13 @@ RCT_EXPORT_METHOD(sendInvitation:(NSDictionary *) invitation
|
||||
return [FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"Failed to handle invitation: %@", [error localizedDescription]);
|
||||
} else if (receivedInvite) {
|
||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:@{
|
||||
@"deepLink": receivedInvite.deepLink,
|
||||
@"invitationId": receivedInvite.inviteId,
|
||||
}];
|
||||
} else if (receivedInvite && receivedInvite.inviteId) {
|
||||
[RNFirebaseUtil sendJSEvent:self name:INVITES_INVITATION_RECEIVED body:@{
|
||||
@"deepLink": receivedInvite.deepLink,
|
||||
@"invitationId": receivedInvite.inviteId,
|
||||
}];
|
||||
} else {
|
||||
[[RNFirebaseLinks instance] sendLink:receivedInvite.deepLink];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options;
|
||||
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler;
|
||||
- (void)sendLink:(NSString *)link;
|
||||
|
||||
@end
|
||||
|
||||
@ -22,3 +23,4 @@
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -39,7 +39,7 @@ RCT_EXPORT_MODULE();
|
||||
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
|
||||
if (dynamicLink && dynamicLink.url) {
|
||||
NSURL* url = dynamicLink.url;
|
||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:url];
|
||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:url.absoluteString];
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
@ -56,7 +56,7 @@ continueUserActivity:(NSUserActivity *)userActivity
|
||||
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
||||
} else {
|
||||
NSURL* url = dynamicLink ? dynamicLink.url : userActivity.webpageURL;
|
||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:url];
|
||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:url.absoluteString];
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -66,11 +66,15 @@ continueUserActivity:(NSUserActivity *)userActivity
|
||||
// ** Finish AppDelegate methods
|
||||
// *******************************************************
|
||||
|
||||
- (void)sendLink:(NSString *)link {
|
||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:link];
|
||||
}
|
||||
|
||||
// ** Start React Module methods **
|
||||
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 {
|
||||
@ -140,11 +144,11 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
|
||||
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) {
|
||||
@ -159,7 +163,7 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
|
||||
if (androidParametersDict) {
|
||||
FIRDynamicLinkAndroidParameters *androidParams = [FIRDynamicLinkAndroidParameters
|
||||
parametersWithPackageName: androidParametersDict[@"androidPackageName"]];
|
||||
|
||||
|
||||
if (androidParametersDict[@"androidFallbackLink"]) {
|
||||
androidParams.fallbackURL = [NSURL URLWithString:androidParametersDict[@"androidFallbackLink"]];
|
||||
}
|
||||
|
@ -10,11 +10,7 @@ import { getNativeModule } from '../../utils/native';
|
||||
|
||||
import type App from '../core/app';
|
||||
|
||||
const EVENT_TYPE = {
|
||||
Link: 'links_link_received',
|
||||
};
|
||||
|
||||
const NATIVE_EVENTS = [EVENT_TYPE.Link];
|
||||
const NATIVE_EVENTS = ['links_link_received'];
|
||||
|
||||
export const MODULE_NAME = 'RNFirebaseLinks';
|
||||
export const NAMESPACE = 'links';
|
||||
@ -94,10 +90,6 @@ export default class Links extends ModuleBase {
|
||||
);
|
||||
}
|
||||
|
||||
get EVENT_TYPE(): Object {
|
||||
return EVENT_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create long Dynamic Link from parameters
|
||||
* @param parameters
|
||||
@ -153,6 +145,4 @@ export default class Links extends ModuleBase {
|
||||
}
|
||||
}
|
||||
|
||||
export const statics = {
|
||||
EVENT_TYPE,
|
||||
};
|
||||
export const statics = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user