Passing data to react-native from native with proguard - react-native

Without proguard=true following is WritableMap which is passed to React native.
{isDone:true}
And I enable obfuscation
{a:true}
I want pro guard not to touch this class. What to add in proguard file?

Add following to proguard-rules.pro:
-keep, includedescriptorclasses public class packagename.model.** {*; }

Related

How to go back to react native activity from android native modules

I implemented android native bridge module in which I call native like below, and I don't know how to navigate back to react native
#ReactMethod public void createMerchantEvent(){ Intent intent = new Intent(getReactApplicationContext(),LoadingActivity.class); getCurrentActivity().startActivity(intent); }

Where can I find my MainActivity.java when running a Android simulator

I just mad my first React native project and I'm trying to lock my screen orientation to landscape. I installed this package
https://github.com/yamill/react-native-orientation#configuration
with npm install react-native link react-native-orientation and now I need to
Implement onConfigurationChanged method in MainActivity.java
So this code
import android.content.Intent; // <--- import
import android.content.res.Configuration; // <--- import
public class MainActivity extends ReactActivity {
......
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Intent intent = new Intent("onConfigurationChanged");
intent.putExtra("newConfig", newConfig);
this.sendBroadcast(intent);
}
......
}
But where can I find that? From what I've seen is that you can find it in a android studio project. But I don't have a project, I just go to the AVD manager to run my virtual device. So where am I supposed to add this code?
The whole aim of expo is to handle everything related to android or ios for you.
Thus, you won't have access to these two folders unless you eject your app from expo as it's explained here on the official doc.
However, if your goal is to handle screen orientation, expo has a built-in API for you that you may find here.
Or even simpler, you could just update your app.json and add this line:
"expo": {
...
"orientation": "landscape"
...
}
Have a look at the official doc if you want to see everything that you can handle with this configuration file.

setting up gradle plugin with DefaultTask to instantiate a class that renders react-native

I am trying to build a module with gradle that starts up a react-native app in a native app. Im following a guide that explains that a class extending from DefaultTask is responsible for the root behavior of the plugin. Going off of that, I want to do something with a file like this. start react app class . Am I on the right track?
public class DemoTask extends DefaultTask {
#TaskAction
public void renderRNSDK() {
}
}

LockModule.init undefined error in auth0 react-android getting started

I'm following the instructions to get auth0 running in react-native android https://auth0.com/docs/quickstart/native/react-native-android
And I am getting the following error
undefined is not an object (evaluating 'LockModule.init') show auth0-lock.js:33
The error implies that the LockModule variable is undefined; by checking the code for auth0-lock.js we can see that the variable is being initialized by the following logic:
var { NativeModules, Platform } = require('react-native');
var LockModule = NativeModules.Auth0LockModule;
According to react-native documentation in order to use a module implemented as a native module you need to register it.
The package needs to be provided in the getPackages method of the MainApplication.java file. This file exists under the android folder in your react-native application directory.
You should have something similar to:
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new LockReactPackage()
);
}
If this is not the root cause of the issue you'll need to update your question with more details.
I ran into this issue while trying to get Auth0 working on iOS. Our fix is here (react-native run-ios to see more detailed messages for the issue; correct header search paths; update podfile with OneSignal; add OneSignal library)
https://github.com/auth0/react-native-lock/issues/133

Linking with android os settings in react native

I'm trying to link with android os settings page.
Going to Phone Dail with Linking is work.
Linking.openURL('tel: +959 XXXXXXXX');
Can I use Linking to link with android os settings page like android location settings page?
Linking.openURL can only open correctly formatted urls. There are no standardized urls for the android settings. You would have to write some native code to do this, and then build a React Native Module to trigger it.
Here is some example Android code:
public void openWifiSettings() {
Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}