claired4l
claired4l

Reputation: 64

How to make WearOS Android App receive message from react-native app native module?

I am trying to use the MessageClient Api https://developers.google.com/android/reference/com/google/android/gms/wearable/MessageClient to send messages between a WearOS Android app and a react-native app using a native module (https://github.com/claired4l/react-native-wear-connectivity/tree/fix/message-client-send-message-interface).

Both apps have the same application ID and the devices are correctly paired.

The communication works perfectly between two android Apps or between two react-native apps. However a hybrid setup of Android and react-native app opposes a heavy resistance. The listener simply never receives any update (no better behaviour using a background service implementing the WearableListenerService).

The code behind sendMessage and onMessageReceived being unknown I am running out of ideas of how to make this work. Has anyone ever encountered this issue and solved it?

Upvotes: 0

Views: 163

Answers (1)

claired4l
claired4l

Reputation: 64

By default react-native provides a keystore in android/app/debug.keystore, which is set in the app gradle file to sign the debug apk. For the android app, there was no predefined keystore which resulted in Android Studio automatically generating a new signature, which was then different from the one used by the React Native apps.

android {
    ...
    defaultConfig {
        ...
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes { 
        ... 
    }
}

When using the same keystore and signature, the Android app and the React Native app were then able to communicate without any further issue.

Upvotes: 0

Related Questions