1.0.0 • Published 3 years ago

react-native-start-activity-for-result v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-native-start-activity-for-result

React Native implementation for Android's native startActivityForResult() and onActivityResult() methods. This can be used for integrations with other apps that require using the previously mentioned methods.

Usage

import startActivityForResult from 'react-native-start-activity-for-result';

startActivityForResult(returnKey, options);

Example

import startActivityForResult from 'react-native-start-activity-for-result';

export const openExternalAppAndGetToken = async (uri: string, extra: Object) => {
    const token = await startActivityForResult('external_app_token', {uri, extra});
    return token;
};

Parameters

ParameterTypeDescription
returnKeystringThe key used for getting data back from the launched app. The launched app has to use putExtra() method when returning data. More information here
optionsObjectOptions that can be passed to the lanched intent (below more information)
options.actionstringThe used intent action (default value is Intent.ACTION_VIEW = "android.intent.action.VIEW"). See more information here.
options.uriUriThe data passed for the intent (uses Intent.setData(Uri data)).
options.extraObjectAll of the extras that are passed for the intent (uses Intent.putExtras(Bundle extras)).

More information about Android intents and their structure here.