align links to v3
This commit is contained in:
parent
3db6a1839b
commit
af4ce2a2ca
|
@ -3,6 +3,7 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __has_include(<FirebaseDynamicLinks/FIRDynamicLinks.h>)
|
||||
#import <Firebase.h>
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTEventEmitter.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#import "RNFirebaseLinks.h"
|
||||
#import "Firebase.h"
|
||||
|
||||
#if __has_include(<FirebaseDynamicLinks/FIRDynamicLink.h>)
|
||||
#import "RNFirebaseEvents.h"
|
||||
|
@ -123,7 +122,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];
|
||||
|
@ -133,7 +132,7 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
|
|||
|
||||
RCT_EXPORT_METHOD(createDynamicLink: (NSDictionary *) metadata resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
||||
FIRDynamicLinkComponents *components = [self getDynamicLinkComponentsFromMetadata:metadata];
|
||||
|
||||
|
||||
if (components == nil) {
|
||||
reject(@"links/failure", @"Failed to create Dynamic Link", nil);
|
||||
} else {
|
||||
|
@ -145,7 +144,7 @@ RCT_EXPORT_METHOD(createDynamicLink: (NSDictionary *) metadata resolver:(RCTProm
|
|||
|
||||
RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
||||
FIRDynamicLinkComponents *components = [self getDynamicLinkComponentsFromMetadata:metadata];
|
||||
|
||||
|
||||
[components shortenWithCompletion:^(NSURL *_Nullable shortURL,
|
||||
NSArray *_Nullable warnings,
|
||||
NSError *_Nullable error) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import RemoteConfig from './modules/config';
|
|||
import Storage, { statics as StorageStatics } from './modules/storage';
|
||||
import Database, { statics as DatabaseStatics } from './modules/database';
|
||||
import Messaging, { statics as MessagingStatics } from './modules/messaging';
|
||||
import Links, { statics as LinksStatics } from './modules/links';
|
||||
|
||||
const FirebaseCoreModule = NativeModules.RNFirebase;
|
||||
|
||||
|
@ -35,6 +36,7 @@ export default class FirebaseApp {
|
|||
this.messaging = this._staticsOrModuleInstance(MessagingStatics, Messaging);
|
||||
this.perf = this._staticsOrModuleInstance({}, Performance);
|
||||
this.storage = this._staticsOrModuleInstance(StorageStatics, Storage);
|
||||
this.links = this._staticsOrModuleInstance(LinksStatics, Links);
|
||||
this._extendedProps = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,29 +1,22 @@
|
|||
import { NativeEventEmitter, NativeModules } from 'react-native'
|
||||
import { Base } from './../base'
|
||||
import { nativeSDKMissing } from './../../utils'
|
||||
|
||||
const FirebaseLinks = NativeModules.RNFirebaseLinks
|
||||
const FirebaseLinksEvt = FirebaseLinks && new NativeEventEmitter(FirebaseLinks)
|
||||
import ModuleBase from './../../utils/ModuleBase';
|
||||
|
||||
const EVENT_TYPE = {
|
||||
Link: 'dynamic_link_received',
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Links
|
||||
*/
|
||||
export default class Links extends Base {
|
||||
constructor(firebase, options = {}) {
|
||||
super(firebase, options)
|
||||
if (!FirebaseLinks) {
|
||||
return nativeSDKMissing('links')
|
||||
}
|
||||
export default class Links extends ModuleBase {
|
||||
static _NAMESPACE = 'links';
|
||||
static _NATIVE_MODULE = 'RNFirebaseLinks';
|
||||
|
||||
this.namespace = 'firebase:links'
|
||||
constructor(firebaseApp: Object, options: Object = {}) {
|
||||
super(firebaseApp, options, true);
|
||||
}
|
||||
|
||||
get EVENT_TYPE() {
|
||||
return EVENT_TYPE
|
||||
return EVENT_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +24,7 @@ export default class Links extends Base {
|
|||
* @returns {*}
|
||||
*/
|
||||
getInitialLink() {
|
||||
return FirebaseLinks.getInitialLink()
|
||||
return this._native.getInitialLink();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,19 +33,19 @@ export default class Links extends Base {
|
|||
* @returns {*}
|
||||
*/
|
||||
onLink(listener: Function): () => any {
|
||||
const rnListener = FirebaseLinksEvt.addListener(EVENT_TYPE.Link, listener)
|
||||
return () => rnListener.remove()
|
||||
const rnListener = this._eventEmitter.addListener(EVENT_TYPE.Link, listener);
|
||||
return () => rnListener.remove();
|
||||
}
|
||||
|
||||
createDynamicLink(parameters: Object = {}): Promise<String> {
|
||||
return FirebaseLinks.createDynamicLink(parameters)
|
||||
return this._native.createDynamicLink(parameters);
|
||||
}
|
||||
|
||||
createShortDynamicLink(parameters: Object = {}): Promise<String> {
|
||||
return FirebaseLinks.createShortDynamicLink(parameters)
|
||||
return this._native.createShortDynamicLink(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
export const statics = {
|
||||
EVENT_TYPE,
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue