naoufal / react-native-safari-view

A React Native wrapper for Safari View Controller.
https://www.npmjs.com/package/react-native-safari-view
494 stars 110 forks source link

[Android] Can't run generate APK #32

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello,

I used the react-native-safari-view in my iOS app, now I want to make an android app. But I can't because the safari view does not support android. How can I make my app run on android?

Like it should work on iOS with this package and on android without this package??

Any Ideas or suggestions for my problem Thanks Alex

naoufal commented 8 years ago

HI @alexanderniebuhr,

I would use WebView as a fallback on Android. The SafariViewController is an iOS only feature that shares cookies and other state between safari and the webview. So you won't get that using the WebView, but at least your app will be functional.

Hope that helps :)

naoufal commented 8 years ago

Can you paste the Error output from generating the APK?

naoufal commented 8 years ago

@alexanderniebuhr can you try changing this line to index.js and attempting to compile your project. If it works, could you submit a PR 😉

https://github.com/naoufal/react-native-safari-view/blob/master/package.json#L5

ghost commented 8 years ago

Hi,

I'll try your suggestions right now. I am coming back with the results.

Still don't Know how to write an appropriate fallback just for android. How do I say react-native "this code On ios and this code On android"

Thanks and hearing later Alexander Niebuhr

ghost commented 8 years ago

Well I actually can generate an apk. But when i run it i get following error and app crashes:

"Requires unknown module "react-native-safari-view"

When I comment the imports and usage of this module, everything works fine

ghost commented 8 years ago

@naoufal the version with package.json does not work for me :(

naoufal commented 8 years ago

@alexanderniebuhr you should be all set after reading this part of the docs.

https://facebook.github.io/react-native/docs/platform-specific-code.html

naoufal commented 8 years ago

Going to close this issue, since it isn't an issue with the module itself. 😉

weinshel commented 8 years ago

I was having a similar issue also. The app would crash on launch only when built in release mode, with the error Requiring unknown module "react-native-safari-view". Since I am using ES6 imports, there isn't an easy way to conditionally require the module for only iOS.

The earlier suggestion to change index.ios.js worked when changed to just index (as opposed to index.js). The app then launched, but then threw a red box error Requiring unknown module "warning". It appears that index.android.js uses the warning module in one line, though it is not listed as a dependency. It worked for me to just remove all references to warning, though I'm not sure if it is important for testing.

I can also open a pull request if you want.

naoufal commented 8 years ago

Hey Ben, I'm not using that warning for testing so you can go ahead with the PR.

On Fri, Aug 19, 2016 at 1:09 AM Ben Weinshel notifications@github.com wrote:

I was having a similar issue also. The app would crash on launch only when built in release mode, with the error Requiring unknown module "react-native-safari-view". Since I am using ES6 imports, there isn't an easy way to conditionally require the module for only iOS.

The earlier suggestion to change index.ios.js worked when changed to just index (as opposed to index.js). The app then launched, but then threw a red box error Requiring unknown module "warning". It appears that index.android.js uses the warning module in one line, though it is not listed as a dependency. It worked for me to just remove all references to warning, though I'm not sure if it is important for testing.

I can also open a pull request if you want.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/naoufal/react-native-safari-view/issues/32#issuecomment-240790676, or mute the thread https://github.com/notifications/unsubscribe-auth/ABjWsGaO155hfcDD9JL-yizN3AvjJQrRks5qhJHGgaJpZM4JTjYK .