[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>)
|
#if __has_include(<FirebaseInvites/FirebaseInvites.h>)
|
||||||
#import "RNFirebaseEvents.h"
|
#import "RNFirebaseEvents.h"
|
||||||
|
#import "RNFirebaseLinks.h"
|
||||||
#import "RNFirebaseUtil.h"
|
#import "RNFirebaseUtil.h"
|
||||||
#import <FirebaseInvites/FirebaseInvites.h>
|
#import <FirebaseInvites/FirebaseInvites.h>
|
||||||
|
|
||||||
@ -155,11 +156,13 @@ RCT_EXPORT_METHOD(sendInvitation:(NSDictionary *) invitation
|
|||||||
return [FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
|
return [FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Failed to handle invitation: %@", [error localizedDescription]);
|
NSLog(@"Failed to handle invitation: %@", [error localizedDescription]);
|
||||||
} else if (receivedInvite) {
|
} else if (receivedInvite && receivedInvite.inviteId) {
|
||||||
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:@{
|
[RNFirebaseUtil sendJSEvent:self name:INVITES_INVITATION_RECEIVED body:@{
|
||||||
@"deepLink": receivedInvite.deepLink,
|
@"deepLink": receivedInvite.deepLink,
|
||||||
@"invitationId": receivedInvite.inviteId,
|
@"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 *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options;
|
||||||
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler;
|
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler;
|
||||||
|
- (void)sendLink:(NSString *)link;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -22,3 +23,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ RCT_EXPORT_MODULE();
|
|||||||
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
|
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
|
||||||
if (dynamicLink && dynamicLink.url) {
|
if (dynamicLink && dynamicLink.url) {
|
||||||
NSURL* url = 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 YES;
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
@ -56,7 +56,7 @@ continueUserActivity:(NSUserActivity *)userActivity
|
|||||||
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
||||||
} else {
|
} else {
|
||||||
NSURL* url = dynamicLink ? dynamicLink.url : userActivity.webpageURL;
|
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,6 +66,10 @@ continueUserActivity:(NSUserActivity *)userActivity
|
|||||||
// ** Finish AppDelegate methods
|
// ** Finish AppDelegate methods
|
||||||
// *******************************************************
|
// *******************************************************
|
||||||
|
|
||||||
|
- (void)sendLink:(NSString *)link {
|
||||||
|
[RNFirebaseUtil sendJSEvent:self name:LINKS_LINK_RECEIVED body:link];
|
||||||
|
}
|
||||||
|
|
||||||
// ** Start React Module methods **
|
// ** Start React Module methods **
|
||||||
RCT_EXPORT_METHOD(createDynamicLink: (NSDictionary *) metadata resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
RCT_EXPORT_METHOD(createDynamicLink: (NSDictionary *) metadata resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
||||||
@try {
|
@try {
|
||||||
|
@ -10,11 +10,7 @@ import { getNativeModule } from '../../utils/native';
|
|||||||
|
|
||||||
import type App from '../core/app';
|
import type App from '../core/app';
|
||||||
|
|
||||||
const EVENT_TYPE = {
|
const NATIVE_EVENTS = ['links_link_received'];
|
||||||
Link: 'links_link_received',
|
|
||||||
};
|
|
||||||
|
|
||||||
const NATIVE_EVENTS = [EVENT_TYPE.Link];
|
|
||||||
|
|
||||||
export const MODULE_NAME = 'RNFirebaseLinks';
|
export const MODULE_NAME = 'RNFirebaseLinks';
|
||||||
export const NAMESPACE = 'links';
|
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
|
* Create long Dynamic Link from parameters
|
||||||
* @param parameters
|
* @param parameters
|
||||||
@ -153,6 +145,4 @@ export default class Links extends ModuleBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const statics = {
|
export const statics = {};
|
||||||
EVENT_TYPE,
|
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user