flatten dynamicLinkInfo to the top-level, move the mandatory keys validation to the javascript from the native modules and some minor fixes
This commit is contained in:
parent
adafa45380
commit
fbdc733d53
|
@ -37,7 +37,7 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
void onResolved(String url);
|
||||
}
|
||||
|
||||
private interface ErrorHandler {
|
||||
private interface ErrorHandler {
|
||||
void onError(Exception e);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
}
|
||||
|
||||
|
||||
private void resloveLink(Intent intent, final ResolveHandler resolveHandler, final ErrorHandler errorHandler) {
|
||||
private void resolveLink(Intent intent, final ResolveHandler resolveHandler, final ErrorHandler errorHandler) {
|
||||
FirebaseDynamicLinks.getInstance()
|
||||
.getDynamicLink(intent)
|
||||
.addOnSuccessListener(new OnSuccessListener<PendingDynamicLinkData>() {
|
||||
|
@ -83,7 +83,7 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
} else {
|
||||
Activity activity = getCurrentActivity();
|
||||
if (activity != null) {
|
||||
resloveLink(activity.getIntent(), new ResolveHandler() {
|
||||
resolveLink(activity.getIntent(), new ResolveHandler() {
|
||||
@Override
|
||||
public void onResolved(String url) {
|
||||
if (url != null) {
|
||||
|
@ -115,7 +115,7 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
resloveLink(intent, new ResolveHandler() {
|
||||
resolveLink(intent, new ResolveHandler() {
|
||||
@Override
|
||||
public void onResolved(String url) {
|
||||
if (url != null) {
|
||||
|
@ -150,9 +150,9 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
@ReactMethod
|
||||
public void createDynamicLink(final ReadableMap parameters, final Promise promise) {
|
||||
try {
|
||||
Map<String, Object> m = Utils.recursivelyDeconstructReadableMap(parameters);
|
||||
Map<String, Object> metaData = Utils.recursivelyDeconstructReadableMap(parameters);
|
||||
|
||||
DynamicLink.Builder builder = getDynamicLinkBuilderFromMap(m);
|
||||
DynamicLink.Builder builder = getDynamicLinkBuilderFromMap(metaData);
|
||||
Uri link = builder.buildDynamicLink().getUri();
|
||||
|
||||
Log.d(TAG, "created dynamic link: " + link.toString());
|
||||
|
@ -166,11 +166,11 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
@ReactMethod
|
||||
public void createShortDynamicLink(final ReadableMap parameters, final Promise promise) {
|
||||
try {
|
||||
Map<String, Object> m = Utils.recursivelyDeconstructReadableMap(parameters);
|
||||
Map<String, Object> metaData = Utils.recursivelyDeconstructReadableMap(parameters);
|
||||
|
||||
DynamicLink.Builder builder = getDynamicLinkBuilderFromMap(m);
|
||||
DynamicLink.Builder builder = getDynamicLinkBuilderFromMap(metaData);
|
||||
|
||||
Task<ShortDynamicLink> shortLinkTask = getShortDynamicLinkTask(builder, m)
|
||||
Task<ShortDynamicLink> shortLinkTask = getShortDynamicLinkTask(builder, metaData)
|
||||
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<ShortDynamicLink> task) {
|
||||
|
@ -190,26 +190,23 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
}
|
||||
}
|
||||
|
||||
private DynamicLink.Builder getDynamicLinkBuilderFromMap(final Map<String, Object> m) {
|
||||
private DynamicLink.Builder getDynamicLinkBuilderFromMap(final Map<String, Object> metaData) {
|
||||
DynamicLink.Builder parametersBuilder = FirebaseDynamicLinks.getInstance().createDynamicLink();
|
||||
Map<String, Object> dynamicLinkInfo = (Map<String, Object>) m.get("dynamicLinkInfo");
|
||||
if (dynamicLinkInfo != null) {
|
||||
try {
|
||||
parametersBuilder.setLink(Uri.parse((String) dynamicLinkInfo.get("link")));
|
||||
parametersBuilder.setDynamicLinkDomain((String) dynamicLinkInfo.get("dynamicLinkDomain"));
|
||||
setAndroidParameters(dynamicLinkInfo, parametersBuilder);
|
||||
setIosParameters(dynamicLinkInfo, parametersBuilder);
|
||||
setSocialMetaTagParameters(dynamicLinkInfo, parametersBuilder);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "error while building parameters " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
parametersBuilder.setLink(Uri.parse((String) metaData.get("link")));
|
||||
parametersBuilder.setDynamicLinkDomain((String) metaData.get("dynamicLinkDomain"));
|
||||
setAndroidParameters(metaData, parametersBuilder);
|
||||
setIosParameters(metaData, parametersBuilder);
|
||||
setSocialMetaTagParameters(metaData, parametersBuilder);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "error while building parameters " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
return parametersBuilder;
|
||||
}
|
||||
|
||||
private Task<ShortDynamicLink> getShortDynamicLinkTask(final DynamicLink.Builder builder, final Map<String, Object> m) {
|
||||
Map<String, Object> suffix = (Map<String, Object>) m.get("suffix");
|
||||
private Task<ShortDynamicLink> getShortDynamicLinkTask(final DynamicLink.Builder builder, final Map<String, Object> metaData) {
|
||||
Map<String, Object> suffix = (Map<String, Object>) metaData.get("suffix");
|
||||
if (suffix != null) {
|
||||
String option = (String) suffix.get("option");
|
||||
if ("SHORT".equals(option)) {
|
||||
|
@ -222,13 +219,9 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
}
|
||||
|
||||
|
||||
private void setAndroidParameters(final Map<String, Object> dynamicLinkInfo, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> androidParameters = (Map<String, Object>) dynamicLinkInfo.get("androidInfo");
|
||||
private void setAndroidParameters(final Map<String, Object> metaData, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> androidParameters = (Map<String, Object>) metaData.get("androidInfo");
|
||||
if (androidParameters != null) {
|
||||
if (!androidParameters.containsKey("androidPackageName")) {
|
||||
throw new IllegalArgumentException("no androidPackageName was specified.");
|
||||
}
|
||||
|
||||
DynamicLink.AndroidParameters.Builder androidParametersBuilder =
|
||||
new DynamicLink.AndroidParameters.Builder((String) androidParameters.get("androidPackageName"));
|
||||
|
||||
|
@ -242,12 +235,9 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
}
|
||||
}
|
||||
|
||||
private void setIosParameters(final Map<String, Object> dynamicLinkInfo, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> iosParameters = (Map<String, Object>) dynamicLinkInfo.get("iosInfo");
|
||||
private void setIosParameters(final Map<String, Object> metaData, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> iosParameters = (Map<String, Object>) metaData.get("iosInfo");
|
||||
if (iosParameters != null) {
|
||||
if (!iosParameters.containsKey("iosBundleId")) {
|
||||
throw new IllegalArgumentException("no iosBundleId was specified.");
|
||||
}
|
||||
DynamicLink.IosParameters.Builder iosParametersBuilder =
|
||||
new DynamicLink.IosParameters.Builder((String) iosParameters.get("iosBundleId"));
|
||||
|
||||
|
@ -273,8 +263,8 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
|||
}
|
||||
}
|
||||
|
||||
private void setSocialMetaTagParameters(final Map<String, Object> dynamicLinkInfo, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> socialMetaTagParameters = (Map<String, Object>) dynamicLinkInfo.get("socialMetaTagInfo");
|
||||
private void setSocialMetaTagParameters(final Map<String, Object> metaData, final DynamicLink.Builder parametersBuilder) {
|
||||
Map<String, Object> socialMetaTagParameters = (Map<String, Object>) metaData.get("socialMetaTagInfo");
|
||||
if (socialMetaTagParameters != null) {
|
||||
DynamicLink.SocialMetaTagParameters.Builder socialMetaTagParametersBuilder =
|
||||
new DynamicLink.SocialMetaTagParameters.Builder();
|
||||
|
|
|
@ -28,18 +28,6 @@ public class RNFirebaseLinksPackage implements ReactPackage {
|
|||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of JS modules to register with the newly created catalyst instance.
|
||||
* <p/>
|
||||
* IMPORTANT: Note that only modules that needs to be accessible from the native code should be
|
||||
* listed here. Also listing a native module here doesn't imply that the JS implementation of it
|
||||
* will be automatically included in the JS bundle.
|
||||
*/
|
||||
// TODO: Removed in 0.47.0. Here for backwards compatability
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reactContext
|
||||
* @return a list of view managers that should be registered with {@link UIManagerModule}
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
- [Cloud Messaging](/modules/cloud-messaging)
|
||||
- [Crash Reporting](/modules/crash)
|
||||
- [Database](/modules/database)
|
||||
- [Firestore (Beta)](/modules/firestore)
|
||||
- [Dynamic Links](/modules/links)
|
||||
- [Firestore (Beta)](/modules/firestore)
|
||||
- [Remote Config](/modules/config)
|
||||
- [Storage](/modules/storage)
|
||||
- [Transactions](/modules/transactions)
|
||||
|
|
|
@ -11,6 +11,7 @@ RNFirebase mimics [Firebase's REST API](https://firebase.google.com/docs/dynamic
|
|||
The differences from the REST API are:
|
||||
1. The input for the methods is a javascript object instead of a JSON object.
|
||||
2. The response contains the URL string only.
|
||||
3. There is no `dynamicLinkInfo` element. Instead, all of the elements under it were moved to be under the top-level.
|
||||
|
||||
### Methods
|
||||
|
||||
|
@ -20,15 +21,13 @@ Creates a long dynamic link.
|
|||
|
||||
```javascript
|
||||
firebase.links().createDynamicLink({
|
||||
dynamicLinkInfo: {
|
||||
dynamicLinkDomain: "abc123.app.goo.gl",
|
||||
link: "https://example.com?param1=foo¶m2=bar",
|
||||
androidInfo: {
|
||||
androidPackageName: "com.example.android"
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: "com.example.ios"
|
||||
}
|
||||
dynamicLinkDomain: "abc123.app.goo.gl",
|
||||
link: "https://example.com?param1=foo¶m2=bar",
|
||||
androidInfo: {
|
||||
androidPackageName: "com.example.android"
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: "com.example.ios"
|
||||
}
|
||||
}).
|
||||
then((url) => {
|
||||
|
@ -41,15 +40,14 @@ then((url) => {
|
|||
Creates a short dynamic link.
|
||||
|
||||
```javascript
|
||||
firebase.links().createShortDynamicLink(dynamicLinkInfo: {
|
||||
dynamicLinkDomain: "abc123.app.goo.gl",
|
||||
link: "https://example.com?param1=foo¶m2=bar",
|
||||
androidInfo: {
|
||||
androidPackageName: "com.example.android"
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: "com.example.ios"
|
||||
}
|
||||
firebase.links().createShortDynamicLink({
|
||||
dynamicLinkDomain: "abc123.app.goo.gl",
|
||||
link: "https://example.com?param1=foo¶m2=bar",
|
||||
androidInfo: {
|
||||
androidPackageName: "com.example.android"
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: "com.example.ios"
|
||||
}
|
||||
}).
|
||||
then((url) => {
|
||||
|
@ -62,35 +60,35 @@ Only the following parameters are currently supported:
|
|||
|
||||
```javascript
|
||||
{
|
||||
dynamicLinkInfo: {
|
||||
dynamicLinkDomain: string,
|
||||
link: string,
|
||||
androidInfo: {
|
||||
androidPackageName: string,
|
||||
androidFallbackLink: string,
|
||||
androidMinPackageVersionCode: string,
|
||||
androidLink: string
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: string,
|
||||
iosFallbackLink: string,
|
||||
iosCustomScheme: string,
|
||||
iosIpadFallbackLink: string,
|
||||
iosIpadBundleId: string,
|
||||
iosAppStoreId: string
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle: string,
|
||||
socialDescription: string,
|
||||
socialImageLink: string
|
||||
}
|
||||
dynamicLinkDomain: 'string',
|
||||
link: 'string',
|
||||
androidInfo: {
|
||||
androidPackageName: 'string',
|
||||
androidFallbackLink: 'string',
|
||||
androidMinPackageVersionCode: 'string',
|
||||
androidLink: 'string',
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: 'string',
|
||||
iosFallbackLink: 'string',
|
||||
iosCustomScheme: 'string',
|
||||
iosIpadFallbackLink: 'string',
|
||||
iosIpadBundleId: 'string',
|
||||
iosAppStoreId: 'string',
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle: 'string',
|
||||
socialDescription: 'string',
|
||||
socialImageLink: 'string',
|
||||
},
|
||||
suffix: {
|
||||
option: "SHORT" or "UNGUESSABLE"
|
||||
}
|
||||
option: 'string',
|
||||
},
|
||||
}
|
||||
```
|
||||
?> Please note that when using `androidInfo` or `iosInfo`, `androidPackageName` and `iosBundleId` are mandatory (respectively).
|
||||
**please note:**
|
||||
1. dynamicLinkDomain and link are mandatory fields. In addition, when using `androidInfo` or `iosInfo`, `androidPackageName` and `iosBundleId` are mandatory (respectively).
|
||||
2. In oppose to the REST API, There is no `dynamicLinkInfo` element. Instead, all of the elements under it were moved to be under the top-level.
|
||||
|
||||
For more information [see reference](https://firebase.google.com/docs/reference/dynamic-links/link-shortener)
|
||||
|
||||
|
|
|
@ -171,15 +171,14 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
|
|||
}
|
||||
|
||||
- (FIRDynamicLinkComponents *)getDynamicLinkComponentsFromMetadata:(NSDictionary *)metadata {
|
||||
NSDictionary* dynamicLinkInfoMetadata = metadata[@"dynamicLinkInfo"];
|
||||
@try {
|
||||
NSURL *link = [NSURL URLWithString:dynamicLinkInfoMetadata[@"link"]];
|
||||
NSURL *link = [NSURL URLWithString:metadata[@"link"]];
|
||||
FIRDynamicLinkComponents *components =
|
||||
[FIRDynamicLinkComponents componentsWithLink:link domain:dynamicLinkInfoMetadata[@"dynamicLinkDomain"]];
|
||||
[FIRDynamicLinkComponents componentsWithLink:link domain:metadata[@"dynamicLinkDomain"]];
|
||||
|
||||
[self setAndroidParameters:dynamicLinkInfoMetadata components:components];
|
||||
[self setIosParameters:dynamicLinkInfoMetadata components:components];
|
||||
[self setSocialMetaTagParameters:dynamicLinkInfoMetadata components:components];
|
||||
[self setAndroidParameters:metadata components:components];
|
||||
[self setIosParameters:metadata components:components];
|
||||
[self setSocialMetaTagParameters:metadata components:components];
|
||||
|
||||
return components;
|
||||
}
|
||||
|
@ -193,12 +192,6 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
|
|||
components:(FIRDynamicLinkComponents *)components {
|
||||
NSDictionary *androidParametersDict = metadata[@"androidInfo"];
|
||||
if (androidParametersDict) {
|
||||
if (!androidParametersDict[@"androidPackageName"]) {
|
||||
@throw [NSException
|
||||
exceptionWithName:@"missing arguments"
|
||||
reason:@"no androidPackageName was specified."
|
||||
userInfo:nil];
|
||||
}
|
||||
FIRDynamicLinkAndroidParameters *androidParams = [FIRDynamicLinkAndroidParameters
|
||||
parametersWithPackageName: androidParametersDict[@"androidPackageName"]];
|
||||
|
||||
|
@ -207,7 +200,6 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
|
|||
}
|
||||
if (androidParametersDict[@"androidMinPackageVersionCode"]) {
|
||||
androidParams.minimumVersion = [androidParametersDict[@"androidMinPackageVersionCode"] integerValue];
|
||||
|
||||
}
|
||||
components.androidParameters = androidParams;
|
||||
}
|
||||
|
@ -217,12 +209,6 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
|
|||
components:(FIRDynamicLinkComponents *)components {
|
||||
NSDictionary *iosParametersDict = metadata[@"iosInfo"];
|
||||
if (iosParametersDict) {
|
||||
if (!iosParametersDict[@"iosBundleId"]) {
|
||||
@throw [NSException
|
||||
exceptionWithName:@"missing arguments"
|
||||
reason:@"no iosBundleId was specified."
|
||||
userInfo:nil];
|
||||
}
|
||||
FIRDynamicLinkIOSParameters *iOSParams = [FIRDynamicLinkIOSParameters
|
||||
parametersWithBundleID:iosParametersDict[@"iosBundleId"]];
|
||||
if (iosParametersDict[@"iosAppStoreId"]) {
|
||||
|
|
|
@ -1,40 +1,55 @@
|
|||
import ModuleBase from './../../utils/ModuleBase';
|
||||
import { areObjectKeysContainedInOther } from './../../utils';
|
||||
import { areObjectKeysContainedInOther, isObject, isString } from './../../utils';
|
||||
|
||||
const EVENT_TYPE = {
|
||||
Link: 'dynamic_link_received',
|
||||
};
|
||||
|
||||
function validateParameters(parameters: Object): boolean {
|
||||
function validateParameters(parameters: Object): void {
|
||||
const suportedParametersObject = {
|
||||
dynamicLinkInfo: {
|
||||
dynamicLinkDomain: 'string',
|
||||
link: 'string',
|
||||
androidInfo: {
|
||||
androidPackageName: 'string',
|
||||
androidFallbackLink: 'string',
|
||||
androidMinPackageVersionCode: 'string',
|
||||
androidLink: 'string',
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: 'string',
|
||||
iosFallbackLink: 'string',
|
||||
iosCustomScheme: 'string',
|
||||
iosIpadFallbackLink: 'string',
|
||||
iosIpadBundleId: 'string',
|
||||
iosAppStoreId: 'string',
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle: 'string',
|
||||
socialDescription: 'string',
|
||||
socialImageLink: 'string',
|
||||
},
|
||||
dynamicLinkDomain: 'string',
|
||||
link: 'string',
|
||||
androidInfo: {
|
||||
androidPackageName: 'string',
|
||||
androidFallbackLink: 'string',
|
||||
androidMinPackageVersionCode: 'string',
|
||||
androidLink: 'string',
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId: 'string',
|
||||
iosFallbackLink: 'string',
|
||||
iosCustomScheme: 'string',
|
||||
iosIpadFallbackLink: 'string',
|
||||
iosIpadBundleId: 'string',
|
||||
iosAppStoreId: 'string',
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle: 'string',
|
||||
socialDescription: 'string',
|
||||
socialImageLink: 'string',
|
||||
},
|
||||
suffix: {
|
||||
option: 'string',
|
||||
},
|
||||
};
|
||||
return areObjectKeysContainedInOther(parameters, suportedParametersObject);
|
||||
if (!areObjectKeysContainedInOther(parameters, suportedParametersObject)) {
|
||||
throw new Error('Invalid Parameters.');
|
||||
}
|
||||
}
|
||||
|
||||
function checkForMandatoryParameters(parameters: Object): void {
|
||||
if (!isString(parameters.dynamicLinkDomain)) {
|
||||
throw new Error('No dynamicLinkDomain was specified.');
|
||||
}
|
||||
if (!isString(parameters.link)) {
|
||||
throw new Error('No link was specified.');
|
||||
}
|
||||
if (isObject(parameters.androidInfo) && !isString(parameters.androidInfo.androidPackageName)) {
|
||||
throw new Error('No androidPackageName was specified.');
|
||||
}
|
||||
if (isObject(parameters.iosInfo) && !isString(parameters.iosInfo.iosBundleId)) {
|
||||
throw new Error('No iosBundleId was specified.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,10 +91,13 @@ export default class Links extends ModuleBase {
|
|||
* @returns {Promise.<String>}
|
||||
*/
|
||||
createDynamicLink(parameters: Object = {}): Promise<String> {
|
||||
if (!validateParameters(parameters)) {
|
||||
return Promise.reject(new Error('Invalid Parameters.'));
|
||||
try {
|
||||
checkForMandatoryParameters(parameters);
|
||||
validateParameters(parameters);
|
||||
return this._native.createDynamicLink(parameters);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
return this._native.createDynamicLink(parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,10 +106,13 @@ export default class Links extends ModuleBase {
|
|||
* @returns {Promise.<String>}
|
||||
*/
|
||||
createShortDynamicLink(parameters: Object = {}): Promise<String> {
|
||||
if (!validateParameters(parameters)) {
|
||||
return Promise.reject(new Error('Invalid Parameters.'));
|
||||
try {
|
||||
checkForMandatoryParameters(parameters);
|
||||
validateParameters(parameters);
|
||||
return this._native.createShortDynamicLink(parameters);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
return this._native.createShortDynamicLink(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,27 +25,25 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
|
||||
it('create long dynamic link with all supported parameters', async () => {
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -79,10 +77,8 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
|
||||
it('create long dynamic link with minimal parameters', async () => {
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
};
|
||||
|
||||
const result = await links.createDynamicLink(data);
|
||||
|
@ -101,8 +97,9 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
reject(new Error('createDynamicLink did not fail.'));
|
||||
}, reject);
|
||||
|
||||
const failure = tryCatch(() => {
|
||||
const failure = tryCatch((error) => {
|
||||
// Assertion
|
||||
error.message.should.equal('No dynamicLinkDomain was specified.');
|
||||
resolve();
|
||||
}, reject);
|
||||
|
||||
|
@ -116,6 +113,29 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
});
|
||||
});
|
||||
|
||||
it('fail to create long dynamic link without link object', () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const success = tryCatch(() => {
|
||||
// Assertion
|
||||
reject(new Error('createDynamicLink did not fail.'));
|
||||
}, reject);
|
||||
|
||||
const failure = tryCatch((error) => {
|
||||
// Assertion
|
||||
error.message.should.equal('No link was specified.');
|
||||
resolve();
|
||||
}, reject);
|
||||
|
||||
const data = { dynamicLinkDomain };
|
||||
|
||||
// Test
|
||||
|
||||
links.createDynamicLink(data)
|
||||
.then(success)
|
||||
.catch(failure);
|
||||
});
|
||||
});
|
||||
|
||||
it('fail to create long dynamic link without iosBundleId', () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const success = tryCatch(() => {
|
||||
|
@ -125,32 +145,30 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
|
||||
const failure = tryCatch((error) => {
|
||||
// Assertion
|
||||
error.message.should.equal('no iosBundleId was specified.');
|
||||
error.message.should.equal('No iosBundleId was specified.');
|
||||
resolve();
|
||||
}, reject);
|
||||
|
||||
// Setup
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -171,32 +189,30 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
|
||||
const failure = tryCatch((error) => {
|
||||
// Assertion
|
||||
error.message.should.equal('no androidPackageName was specified.');
|
||||
error.message.should.equal('No androidPackageName was specified.');
|
||||
resolve();
|
||||
}, reject);
|
||||
|
||||
// Setup
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -208,7 +224,7 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
});
|
||||
});
|
||||
|
||||
it('fail to create long dynamic link with unsupported dynamicLinkInfo parameters', () => {
|
||||
it('fail to create long dynamic link with unsupported parameter', () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const success = tryCatch(() => {
|
||||
// Assertion
|
||||
|
@ -222,11 +238,9 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
}, reject);
|
||||
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
someInvalidParameter: 'invalid',
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
someInvalidParameter: 'invalid',
|
||||
};
|
||||
|
||||
// Test
|
||||
|
@ -251,17 +265,15 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
}, reject);
|
||||
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
someInvalidParameter: 'invalid',
|
||||
someOtherParameter: 'invalid',
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
someInvalidParameter: 'invalid',
|
||||
someOtherParameter: 'invalid',
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -287,17 +299,15 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
}, reject);
|
||||
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
someInvalidParameter: 'invalid',
|
||||
someOtherParameter: 'invalid',
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
someInvalidParameter: 'invalid',
|
||||
someOtherParameter: 'invalid',
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -323,19 +333,17 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
}, reject);
|
||||
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
someInvalidParameter: 'invalid',
|
||||
someOtherParameter: 'invalid',
|
||||
},
|
||||
link,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
someInvalidParameter: 'invalid',
|
||||
someOtherParameter: 'invalid',
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -350,27 +358,25 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
it('create short (unguessable) dynamic link with all supported parameters', async () => {
|
||||
const url = 'https://www.google.co.il/search?q=react+native+firebase';
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link: url,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
link: url,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -384,27 +390,25 @@ function linksTests({ describe, it, firebase, tryCatch }) {
|
|||
it('create short (short) dynamic link with all supported parameters', async () => {
|
||||
const url = 'https://www.google.co.il/search?q=react+native+firebase';
|
||||
const data = {
|
||||
dynamicLinkInfo: {
|
||||
link: url,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
link: url,
|
||||
dynamicLinkDomain,
|
||||
androidInfo: {
|
||||
androidPackageName,
|
||||
androidFallbackLink,
|
||||
androidMinPackageVersionCode,
|
||||
},
|
||||
iosInfo: {
|
||||
iosBundleId,
|
||||
iosFallbackLink,
|
||||
iosCustomScheme,
|
||||
iosIpadFallbackLink,
|
||||
iosIpadBundleId,
|
||||
iosAppStoreId,
|
||||
},
|
||||
socialMetaTagInfo: {
|
||||
socialTitle,
|
||||
socialDescription,
|
||||
socialImageLink,
|
||||
},
|
||||
suffix: {
|
||||
option: 'SHORT',
|
||||
|
|
Loading…
Reference in New Issue