Last active
March 15, 2019 12:37
-
-
Save xvonabur/76c2d2fb1b8dffd5ae86ba4873e8825d to your computer and use it in GitHub Desktop.
Example of App.js for wix react-native-navigation v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Navigation } from 'react-native-navigation' | |
import { Platform } from 'react-native' | |
import { iconsMap, iconsLoaded } from '../Images/VectorIcons' | |
const startApp = () => { | |
iconsLoaded.then(() => | |
Navigation.startSingleScreenApp({ | |
screen: { | |
screen: 'MainScreen', | |
navigatorButtons: { | |
leftButtons: [menuLeftButtonAttrs(iconsMap)] | |
} | |
}, | |
drawer: { | |
left: { | |
screen: 'insteam.Drawer' | |
} | |
}, | |
animationType: getAnimationType(), | |
portraitOnlyMode: true, | |
appStyle: { | |
orientation: 'auto', | |
keepStyleAcrossPush: false, | |
hideBackButtonTitle: true | |
} | |
}).catch(error => console.error(error)) | |
) | |
} | |
class App extends Component { | |
constructor(props) { | |
super(props) | |
if (Platform.OS === 'ios') { | |
startApp() | |
} else { | |
Navigation.isAppLaunched().then(appLaunched => { | |
if (appLaunched) { | |
startApp() | |
} | |
new NativeEventsReceiver().appLaunched(startApp) | |
}) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.insteam2.android; | |
import android.app.Activity; | |
import com.oblador.keychain.KeychainPackage; | |
import com.RNFetchBlob.RNFetchBlobPackage; | |
import io.sentry.RNSentryPackage; | |
import com.github.yamill.orientation.OrientationPackage; | |
import com.brentvatne.react.ReactVideoPackage; | |
import com.burnweb.rnsendintent.RNSendIntentPackage; | |
import com.rnimmersive.RNImmersivePackage; | |
import com.AlexanderZaytsev.RNI18n.RNI18nPackage; | |
import com.learnium.RNDeviceInfo.RNDeviceInfo; | |
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; | |
import com.oblador.vectoricons.VectorIconsPackage; | |
import com.facebook.react.ReactPackage; | |
import com.facebook.react.shell.MainReactPackage; | |
import com.facebook.soloader.SoLoader; | |
import com.wix.reactnativenotifications.RNNotificationsPackage; | |
import java.util.Arrays; | |
import java.util.List; | |
import com.reactnativenavigation.NavigationApplication; | |
import com.wix.reactnativenotifications.core.AppLaunchHelper; | |
import com.wix.reactnativenotifications.core.AppLifecycleFacade; | |
import com.wix.reactnativenotifications.core.BitmapLoader; | |
import com.wix.reactnativenotifications.core.JsIOHelper; | |
import com.wix.reactnativenotifications.core.notifications.ILocalNotification; | |
import com.wix.reactnativenotifications.core.notifications.INotificationsApplication; | |
import com.wix.reactnativenotifications.core.notifications.NotificationProps; | |
import android.content.Context; | |
public class MainApplication extends NavigationApplication implements INotificationsApplication { | |
private NotificationsLifecycleFacade notificationsLifecycleFacade; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
SoLoader.init(this, /* native exopackage */ false); | |
// Create an object of the custom facade impl | |
notificationsLifecycleFacade = new NotificationsLifecycleFacade(); | |
// Attach it to react-native-navigation | |
setActivityCallbacks(notificationsLifecycleFacade); | |
} | |
@Override | |
public boolean isDebug() { | |
// Make sure you are using BuildConfig from your own application | |
return BuildConfig.DEBUG; | |
} | |
protected List<ReactPackage> getPackages() { | |
// Add additional packages you require here | |
// No need to add RnnPackage and MainReactPackage | |
return Arrays.<ReactPackage>asList( | |
new MainReactPackage(), | |
new KeychainPackage(), | |
new RNFetchBlobPackage(), | |
new RNSentryPackage(), | |
new OrientationPackage(), | |
new ReactVideoPackage(), | |
new RNSendIntentPackage(), | |
new RNDeviceInfo(), | |
new ReactNativeConfigPackage(), | |
new RNI18nPackage(), | |
new VectorIconsPackage(), | |
new RNImmersivePackage(), | |
new RNNotificationsPackage(MainApplication.this) | |
); | |
} | |
@Override | |
public List<ReactPackage> createAdditionalReactPackages() { | |
return getPackages(); | |
} | |
@Override | |
public String getJSMainModuleName() { | |
return "index"; | |
} | |
@Override | |
public boolean clearHostOnActivityDestroy(Activity activity) { | |
return false; | |
} | |
@Override | |
public ILocalNotification getLocalNotification(Context context, NotificationProps notificationProps, | |
AppLifecycleFacade facade, AppLaunchHelper defaultAppLaunchHelper) { | |
return new CustomPushNotification( | |
context, | |
notificationProps, | |
notificationsLifecycleFacade, // Instead of defaultFacade!!! | |
defaultAppLaunchHelper, | |
new JsIOHelper(context), | |
new BitmapLoader(context) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment