diff --git a/.gitignore b/.gitignore index 18b7c27b4..4899cde14 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ coverage/ buck-out/ \.buckd/ *.keystore +!debug.keystore # fastlane # diff --git a/android/app/build.gradle b/android/app/build.gradle index 5086c1de1..94c0e2596 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -151,6 +151,12 @@ android { keyPassword KEY_PASSWORD } } + debug { + storeFile project.rootProject.file('debug.keystore').getCanonicalFile() + storePassword "android" + keyAlias "androiddebugkey" + keyPassword "android" + } } splits { abi { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cf2faf448..76c97ae38 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ diff --git a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java index da2d6a82b..0ec4c2b02 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java +++ b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java @@ -4,6 +4,7 @@ import android.app.Application; import android.util.Log; import android.content.Context; import android.os.Bundle; +import android.content.SharedPreferences; import com.facebook.react.PackageList; import com.facebook.hermes.reactexecutor.HermesExecutorFactory; @@ -75,6 +76,20 @@ public class MainApplication extends Application implements ReactApplication, IN public void onCreate() { super.onCreate(); 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 diff --git a/android/debug.keystore b/android/debug.keystore new file mode 100644 index 000000000..30d607ced Binary files /dev/null and b/android/debug.keystore differ diff --git a/app/constants/credentials.js b/app/constants/credentials.js index b04ffd7e0..16fdaed41 100644 --- a/app/constants/credentials.js +++ b/app/constants/credentials.js @@ -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). -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 SERVERS = isIOS ? 'kServers' : 'ACCOUNTS_KEY'; diff --git a/app/sagas/init.js b/app/sagas/init.js index ca0374f7e..9012ff3b7 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -30,6 +30,8 @@ const restore = function* restore() { }); let servers = yield RNUserDefaults.objectForKey(SERVERS); + + console.log(servers); // if not have current if (servers && servers.length !== 0 && (!token || !server)) { server = servers[0][SERVER_URL];