Cómo crear en React Native una Share Extension

React Native y Share Extensions desde cero.

Image for post
Image for post
Image for post
Image for post
Share Extension con React Native

0. Situación inicial

Image for post
Image for post
React Native Share Extension

1. React Native Share Extension

No os olvidéis de linkar las librerías extra

Añadir soporte para compartir imágenes

Image for post
Image for post
NSExtensionActivationSupportsImageWithMaxCount
// path a la imagen
const { value } = await ShareExtension.data();

Fuentes personalizadas

Image for post
Image for post
Image for post
Image for post

MainQueue warning

@implementation AppExtension...+ (BOOL)requiresMainQueueSetup
{
return YES;
}
@end

Paso a producción

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
export NODE_BINARY=node../node_modules/react-native/scripts/react-native-xcode.sh
Image for post
Image for post

2. Código de la extensión

Rehidratando redux

Image for post
Image for post
import storage from 'redux-persist/lib/storage' 
// defaults to AsyncStorage for react-native

import rootReducer from './reducers'

const persistConfig = {
key: 'root',
storage,
}
Image for post
Image for post
App Groups
Image for post
Image for post
import FSStorage from 'redux-persist-fs-storage';
import RNFS from 'react-native-fs';
const getFSStorage = () => Platform.OS === ‘ios’ ? RNFS.pathForGroup(‘group.app.appName’).then(folder => FSStorage(folder)) : Promise.resolve(FSStorage());

3. Conclusiones

¿Quieres recibir más artículos como este?

Entre paseo y paseo con Simba desarrollo en Symfony y React

Get the Medium app