cometchat / chat-sdk-react-native

Voice & Video Calling and Text Chat SDK for React Native
Other
18 stars 17 forks source link

Async Storage gets cleared on logout/login. #2

Closed mayur-bhandari closed 4 years ago

mayur-bhandari commented 4 years ago

https://forum.cometchat.com/t/app-sync-storage-cleared-on-login-user/769

mike-van commented 4 years ago

FYI, im using React Native SDK v2.0.7-beta1

mayur-bhandari commented 4 years ago

This issue has been resolved in v2.0.8-beta2.

mike-van commented 4 years ago

Hi can u reopen this issue? my async storage is still being cleared as im on 2.0.8-beta2 now

mike-van commented 4 years ago

i tried installiing the v2.1.0-beta1 as it support the calling which i'll be needing very shortly, it crash when i tried to rebuild the app on the device.

mayur-bhandari commented 4 years ago

Hello @Mike-Van, What issue are you facing related to Async Storage? Also can you please let us know what error are you getting while building the app in v2.1.0-beta1?

mike-van commented 4 years ago

so regarding the async storage, seems like its working fine. i had to do a clean reinstall of the app. but its no longer clearing the storage now :D. however regarding the build error for v2.1.0-beta1. here's what i got trying to build the app into the phone.

> Task :react-native-calendar-events:compileDebugJavaWithJavac FAILED
/Users/mike/Desktop/ConsumerApp/node_modules/react-native-calendar-events/android/src/main/java/com/calendarevents/CalendarEvents.java:13: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
                             ^
  symbol:   class ActivityCompat
  location: package android.support.v4.app
/Users/mike/Desktop/ConsumerApp/node_modules/react-native-calendar-events/android/src/main/java/com/calendarevents/CalendarEvents.java:14: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
                                 ^
/Users/mike/Desktop/ConsumerApp/node_modules/react-native-calendar-events/android/src/main/java/com/calendarevents/CalendarEvents.java:70: error: cannot find symbol
        ActivityCompat.requestPermissions(currentActivity, new String[]{
        ^
  symbol:   variable ActivityCompat
  location: class CalendarEvents
/Users/mike/Desktop/ConsumerApp/node_modules/react-native-calendar-events/android/src/main/java/com/calendarevents/CalendarEvents.java:94: error: cannot find symbol
        int writePermission = ContextCompat.checkSelfPermission(reactContext, Manifest.permission.WRITE_CALENDAR);
                              ^
  symbol:   variable ContextCompat
  location: class CalendarEvents
/Users/mike/Desktop/ConsumerApp/node_modules/react-native-calendar-events/android/src/main/java/com/calendarevents/CalendarEvents.java:95: error: cannot find symbol
        int readPermission = ContextCompat.checkSelfPermission(reactContext, Manifest.permission.READ_CALENDAR);
                             ^
  symbol:   variable ContextCompat
  location: class CalendarEvents
5 errors

it seems to be the problems with one of the calendar event modules that comes with the comet chat package?

mike-van commented 4 years ago

i tried remove node_modules and re install again, do npx jetify and react-native start --clear-cache i can build the app successfully, but my app crash when launching

jitvarpatil commented 4 years ago

@Mike-Van the error above is Android x build-time error and yes it should be solved after running npx jetify. Can you please confirm that you are getting the same error at the runtime if not can you please send the error log you are getting at runtime so that we can provide you with a precise solution.

Thank you

mike-van commented 4 years ago

Hi yeah. thats what weird. im not getting any error output. i can build the app successfully and then when i launch the app on my phone. it just crashed

mike-van commented 4 years ago
error: bundling failed: Error: Unable to resolve module `./internal/deprecatedSubscriptions` from `node_modules/@react-native-community/netinfo/src/index.ts`:

None of these files exist:
  * node_modules/@react-native-community/netinfo/src/internal/deprecatedSubscriptions(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * node_modules/@react-native-community/netinfo/src/internal/deprecatedSubscriptions/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
    at ModuleResolver.resolveDependency (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
    at Object.resolve (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/lib/transformHelpers.js:267:42)
    at dependencies.map.result (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:426:31)
    at Array.map (<anonymous>)
    at resolveDependencies (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:423:18)
    at /Users/mike/Desktop/ConsumerApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/mike/Desktop/ConsumerApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)

i tried rebuilding the app on an android emulator Pixel_3_XL and when the app launch , i gets this error when bundling the app

mayur-bhandari commented 4 years ago

Hello @Mike-Van,

Can you please let us know what version of React Native are you using? Also, please make sure you are using an RN version greater than 0.59. Also, It can be an issue with the metro packager using a cached version of the library. You might need to kill it and then restart it. You can also add the --reset-cache flag to reset all of the caches that it uses.

mike-van commented 4 years ago

Hi mayur, thanks for the suggestion. Im on react-native v0.61.2. After setting --reset-cache i can bundle the app successfully on the emulator with no above error, but the app just crashed afterward

mayur-bhandari commented 4 years ago

Hello @Mike-Van,

Can you please provide us the stack trace. It would be helpful for us to solve your issue at the soonest.

mike-van commented 4 years ago

Hi @mayur-bhandari , i think i might found the problem. The problem is with the library building process during npm install of the package. If i removed my whole nodes_modules/ folder and reinstall everything along with the v2.1.0-beta1 of the package. i can't find the @cometchat-pro folder in the node_modules folders. but with v2.0.8 is fine. i assume thats why it crashed my app. Also i tried running the app on ios emulator, it also throw modules not found error where i import the comet-chat module.

mike-van commented 4 years ago

also i can see that it appends to my package.json and package-lock.json just fine. n here is my npm install log.

> @cometchat-pro/react-native-chat@2.1.0-beta1 postinstall /Users/mike/Desktop/ConsumerApp/node_modules/@cometchat-pro/react-native-chat
> cd ../.. && npm install --save react-native-cometchat-calling-component@1.2.5 react-native-google-signin@2.0.0 react-native-background-timer@2.1.1 react-native-callstats@3.61.0 react-native-immersive@2.0.0 react-native-keep-awake@4.0.0 react-native-linear-gradient@2.5.6 react-native-sound@0.11.0 react-native-sound@0.11.0 react-native-svg@9.7.1 react-native-svg-transformer@0.13.0 react-native-swipeout@2.3.6 react-native-watch-connectivity@0.2.0 react-native-webrtc@1.75.2 react-native-webview@7.4.1 @react-native-community/netinfo@4.1.5 react-native-calendar-events@github:jitsi/react-native-calendar-events#902e6e92d6bae450a6052f76ba4d02f977ffd8f2

npm WARN deprecated react-native-google-signin@2.0.0: react-native-google-signin has moved to @react-native-community/google-signin
npm WARN deprecated core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @react-native-community/image-editor@2.2.0 requires a peer of react-native@>=0.57 <0.60 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
npm WARN @react-native-community/netinfo@2.0.10 requires a peer of react-native@>=0.57 <0.60 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.1 requires a peer of react@16.0.0-alpha.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.1 requires a peer of react-native@^0.44.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-webview@5.8.1 requires a peer of react-native@>=0.57 <0.60 but none is installed. You must install peer dependencies yourself.
npm WARN react-dom@16.13.1 requires a peer of react@^16.13.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-google-maps@9.4.5 requires a peer of @types/googlemaps@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-google-maps@9.4.5 requires a peer of @types/markerclustererplus@^2.1.29 but none is installed. You must install peer dependencies yourself.
npm WARN react-google-maps@9.4.5 requires a peer of @types/react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@0.18.5 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-fs@2.16.2 requires a peer of react-native@^0.59.5 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-fs@2.16.2 requires a peer of react-native-windows@^0.57.2 but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-stack@1.10.3 requires a peer of react-native-screens@^1.0.0 || ^1.0.0-alpha but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-tabs@2.6.0 requires a peer of react-native-screens@^1.0.0 || ^1.0.0-alpha but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN react-native-cometchat-calling-component@1.2.5 requires a peer of react-native@0.61.3 but none is installed. You must install peer dependencies yourself.

+ react-native-google-signin@2.0.0
+ react-native-immersive@2.0.0
+ react-native-sound@0.11.0
+ react-native-sound@0.11.0
+ react-native-linear-gradient@2.5.6
+ react-native-callstats@3.61.0
+ react-native-background-timer@2.1.1
+ react-native-keep-awake@4.0.0
+ react-native-svg@9.7.1
+ react-native-svg-transformer@0.13.0
+ react-native-swipeout@2.3.6
+ react-native-webrtc@1.75.2
+ react-native-webview@7.4.1
+ react-native-watch-connectivity@0.2.0
+ @react-native-community/netinfo@4.1.5
+ react-native-cometchat-calling-component@1.2.5
+ react-native-calendar-events@1.7.3
removed 11 packages, updated 16 packages and audited 1966474 packages in 130.714s

6 packages are looking for funding
  run `npm fund` for details

found 1319 vulnerabilities (1291 low, 28 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details
npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @react-native-community/image-editor@2.2.0 requires a peer of react-native@>=0.57 <0.60 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
npm WARN @react-native-community/netinfo@2.0.10 requires a peer of react-native@>=0.57 <0.60 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.1 requires a peer of react@16.0.0-alpha.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.1 requires a peer of react-native@^0.44.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-webview@5.8.1 requires a peer of react-native@>=0.57 <0.60 but none is installed. You must install peer dependencies yourself.
npm WARN react-dom@16.13.1 requires a peer of react@^16.13.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-google-maps@9.4.5 requires a peer of @types/googlemaps@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-google-maps@9.4.5 requires a peer of @types/markerclustererplus@^2.1.29 but none is installed. You must install peer dependencies yourself.
npm WARN react-google-maps@9.4.5 requires a peer of @types/react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-cometchat-calling-component@1.2.5 requires a peer of react-native-background-timer@2.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-cometchat-calling-component@1.2.5 requires a peer of react-native@0.61.3 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@0.18.5 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-fs@2.16.2 requires a peer of react-native@^0.59.5 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-fs@2.16.2 requires a peer of react-native-windows@^0.57.2 but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-stack@1.10.3 requires a peer of react-native-screens@^1.0.0 || ^1.0.0-alpha but none is installed. You must install peer dependencies yourself.
npm WARN react-navigation-tabs@2.6.0 requires a peer of react-native-screens@^1.0.0 || ^1.0.0-alpha but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.

+ @cometchat-pro/react-native-chat@2.1.0-beta1
mayur-bhandari commented 4 years ago

Can you run npm install once again without deleting the node_modules folder and build the project.

mike-van commented 4 years ago

i tried that, and now it's giving me the error Invariant violation: native module cannot be null.

mike-van commented 4 years ago

and i can see @comet-chat folder inside the node_modules now.

mayur-bhandari commented 4 years ago

The native module cannot be null means the package has not been successfully installed. Can you please clean npm cache, then again run npm install and build the app. If you still face any issues please let us know.

mike-van commented 4 years ago

Hi @mayur-bhandari im still seeing that cannot be null error. basically here're all my command in one line

cd ios && rm -rf Pods && cd ../android && ./gradlew clean && cd ../ && rm -rf node_modules/ && npm i && npm i --save @cometchat-pro/react-native-chat@2.1.0-beta1 && cd ios && pod install && react-native start --reset-cache --verbose

i ald have @cometchat-pro/react-native-chat in my package json, so i essentially installed the package twice here, only then i can see the @cometchat-pro folder in node_modules/ folder. then i open the app workspace file and xcode, Clean Build Folder -> Build -> Run. is there anything im missing here?

mike-van commented 4 years ago

I tried installing the package on a fresh react-native app, now i get this error with WebView. cant find any solution for this so far.

info Installing the app...

> Configure project :react-native-cometchat-calling-component
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/mike/Desktop/TestChat/node_modules/react-native-webview/android/build.gradle' line: 26

* What went wrong:
A problem occurred evaluating project ':react-native-webview'.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-webview'.
> compileSdkVersion is not specified.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================

* Get more help at https://help.gradle.org

i already have specified my compileSdkVersion and buildToolsVersion in app/build.gradle file. I even added the buildToolsVersion to app gradle like below. but not running still. even specify the value directly there

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

root gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.2")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}
mayur-bhandari commented 4 years ago

Hello @Mike-Van , we have updated our sample app with the calling component. Can you please clone the repo and run a few commands

  1. npm install.
  2. cd ios && pod install

And then run the app and let us know if you are still facing such issues?

Link to the sample app: https://github.com/cometchat-pro-samples/react-native-chat-app

mike-van commented 4 years ago

Hi. thanks for the updated sample app. i managed to run it but got an error when accepting both voice and video call. Undefined is not an object. Evaluating i.peerconnection.addTrack()

mayur-bhandari commented 4 years ago

Hi. thanks for the updated sample app. i managed to run it but got an error when accepting both voice and video call. Undefined is not an object. Evaluating i.peerconnection.addTrack()

Please track the progress of this issue here.

mayur-bhandari commented 4 years ago

The Async Storage issue has been resolved in v2.0.8.