Merge pull request #34744 from johngeorgewright/feature/react-native-app-link

feat: 🎸 add react-native-app-link types
This commit is contained in:
Armando Aguirre
2019-04-15 15:40:58 -07:00
committed by GitHub
4 changed files with 83 additions and 0 deletions

22
types/react-native-app-link/index.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
// Type definitions for react-native-app-link 1.0
// Project: https://github.com/datwheat/react-native-app-link#readme
// Definitions by: John Wright <https://github.com/johngeorgewright>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface AppLinkOptions {
readonly appName: string;
readonly appStoreId: number;
readonly appStoreLocale: string;
readonly playStoreId: string;
}
declare namespace AppLink {
function maybeOpenURL(url: string, options: AppLinkOptions): Promise<void>;
function openInStore(options: AppLinkOptions): Promise<void>;
}
export default AppLink;
import maybeOpenURL = AppLink.maybeOpenURL;
import openInStore = AppLink.openInStore;
export { maybeOpenURL, openInStore };

View File

@@ -0,0 +1,37 @@
import AppLink, { maybeOpenURL, openInStore } from 'react-native-app-link';
AppLink.maybeOpenURL('instagram://user?username=microsoft', {
appName: 'instagram',
appStoreId: 389801252,
appStoreLocale: 'gb',
playStoreId: 'com.instagram.android'
}).then(() => {
// do stuff
});
maybeOpenURL('instagram://user?username=microsoft', {
appName: 'instagram',
appStoreId: 389801252,
appStoreLocale: 'gb',
playStoreId: 'com.instagram.android'
}).then(() => {
// do stuff
});
AppLink.openInStore({
appName: 'whatsapp-messenger',
appStoreId: 310633997,
appStoreLocale: 'gb',
playStoreId: 'com.whatsapp'
}).then(() => {
// do stuff
});
openInStore({
appName: 'whatsapp-messenger',
appStoreId: 310633997,
appStoreLocale: 'gb',
playStoreId: 'com.whatsapp'
}).then(() => {
// do stuff
});

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"react-native-app-link-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }