Try to share credentials by shareUserId
This commit is contained in:
parent
d9aa9514b3
commit
764942c812
|
@ -48,6 +48,7 @@ coverage/
|
||||||
buck-out/
|
buck-out/
|
||||||
\.buckd/
|
\.buckd/
|
||||||
*.keystore
|
*.keystore
|
||||||
|
!debug.keystore
|
||||||
|
|
||||||
# fastlane
|
# fastlane
|
||||||
#
|
#
|
||||||
|
|
|
@ -151,6 +151,12 @@ android {
|
||||||
keyPassword KEY_PASSWORD
|
keyPassword KEY_PASSWORD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debug {
|
||||||
|
storeFile project.rootProject.file('debug.keystore').getCanonicalFile()
|
||||||
|
storePassword "android"
|
||||||
|
keyAlias "androiddebugkey"
|
||||||
|
keyPassword "android"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:sharedUserId="chat.rocket.android"
|
||||||
package="chat.rocket.reactnative">
|
package="chat.rocket.reactnative">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Application;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import com.facebook.react.PackageList;
|
import com.facebook.react.PackageList;
|
||||||
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
|
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
|
||||||
|
@ -75,6 +76,20 @@ public class MainApplication extends Application implements ReactApplication, IN
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
SoLoader.init(this, /* native exopackage */ false);
|
SoLoader.init(this, /* native exopackage */ false);
|
||||||
|
setupContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupContext() {
|
||||||
|
try {
|
||||||
|
Context context = this.createPackageContext("chat.rocket.android", Context.CONTEXT_INCLUDE_CODE);
|
||||||
|
SharedPreferences pref = context.getSharedPreferences("chat.rocket.android", Context.MODE_PRIVATE);
|
||||||
|
String event = pref.getString("ACCOUNTS_KEY", null);
|
||||||
|
Log.d("ACCOUNTS_KEY", "Pegou ${event}");
|
||||||
|
} catch (Exception e) {
|
||||||
|
String error = e.getMessage();
|
||||||
|
Log.d("ACCOUNTS_KEY", "${error}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
// This file hosts the constants with the values used on native apps (User Defaults on iOS and Shared Preferences on Android).
|
// This file hosts the constants with the values used on native apps (User Defaults on iOS and Shared Preferences on Android).
|
||||||
import { isIOS } from '../utils/deviceInfo';
|
import { isIOS, isAndroid } from '../utils/deviceInfo'; // TODO: remove it
|
||||||
|
|
||||||
export const IDENTIFIER = isIOS ? 'group.ios.chat.rocket' : 'chat.rocket.android';
|
export const IDENTIFIER = isIOS ? 'group.ios.chat.rocket' : 'chat.rocket.android';
|
||||||
export const SERVERS = isIOS ? 'kServers' : 'ACCOUNTS_KEY';
|
export const SERVERS = isIOS ? 'kServers' : 'ACCOUNTS_KEY';
|
||||||
|
|
|
@ -30,6 +30,8 @@ const restore = function* restore() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let servers = yield RNUserDefaults.objectForKey(SERVERS);
|
let servers = yield RNUserDefaults.objectForKey(SERVERS);
|
||||||
|
|
||||||
|
console.log(servers);
|
||||||
// if not have current
|
// if not have current
|
||||||
if (servers && servers.length !== 0 && (!token || !server)) {
|
if (servers && servers.length !== 0 && (!token || !server)) {
|
||||||
server = servers[0][SERVER_URL];
|
server = servers[0][SERVER_URL];
|
||||||
|
|
Loading…
Reference in New Issue