HMS-Core / hms-react-native-plugin

This repo contains all of React-Native HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
245 stars 68 forks source link

Unable to generate token #54

Closed neilakoh closed 3 years ago

neilakoh commented 3 years ago

Description I get an error whenever I call the getToken function. The error is:

[getToken] Error/Exception: {"nativeStackAndroid":[],"userInfo":null,"message":"6003: certificate fingerprint error","code":"907122045","line":2242,"column":45,"sourceURL":"http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false"}

I already added enabled the push kit, added the SHA-256 certificate fingerprint, added the agconnect-services.json inside my android/app folder. Setup my gradle:

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        google()
        jcenter()
        maven {url 'https://plugins.gradle.org/m2/'}
        maven {url 'https://developer.huawei.com/repo/'}
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.9, 0.99.99]'
        classpath 'com.huawei.agconnect:agcp:1.2.1.301'
        // 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' }
        maven {url 'https://developer.huawei.com/repo/'}
    }
}

and added

implementation 'com.huawei.hms:push:4.0.3.300' implementation project(':react-native-hms-push')

Not sure what went wrong based on the error it generated.

Expected behavior It should return a token

Current behavior returns an error:

[getToken] Error/Exception: {"nativeStackAndroid":[],"userInfo":null,"message":"6003: certificate fingerprint error","code":"907122045","line":2242,"column":45,"sourceURL":"http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false"}

Screenshots If applicable, add screenshots to help explain your issue

Environment "@hmscore/react-native-hms-push": "^5.0.2-301", "react": "16.13.1", "react-native": "0.63.4",

ozan-yavuz commented 3 years ago

Hi,

The error code 6003 indicates that there's an issue with keystore file configurations. You may see the error code table here. For the error you've encountered, please follow the instructions in the "Suggestion" column.

MuhdSaifulnizam15 commented 3 years ago

Hi, I encounter this issue when I try to call getToken method using the cloud debugging.

[getToken] Error/Exception: {"nativeStackAndroid":[], "userinfo":null, "message":"907135000: arguments invalid", "code": "907122045", "line": 18, "column": 1111, "sourceURL":"index.android.bundle"}

And this when I using my device (Realme 6)

Note that I have check using react-native-device-info wheteher this device support hms. It return true so Im assuming that we should able to get the token.

[getToken] Error/Exception: {"nativeStackAndroid":[],"userInfo":null,"message":"907135003: client api invalid","code":"907122045"}

I have follow all the development guide provided in the huawei developer on how to integrate HMS Core Push Kit in react native. Just that I need to uncomment this line in MainApplication.java due to autolinking.

// packages.add(new HmsPushPackage());

I have check here for the error code description

"907135000" - HmsPushResultCode.ERROR_INTERNAL_ERROR - Internal error. Contact Huawei technical support.
"907122045" - HmsPushResultCode.ERROR_UNKNOWN - Unknown error. Contact Huawei technical support.

Any idea what going wrong here? I get a response calling getId, getAAID, getCreationTIme, enable/disable autoInit and IsAutoInitEnabled method.

ozan-yavuz commented 3 years ago

Hi,

The error message 907135000 means the SDK is misconfigured, please check the instructions here and compare with your own configurations. As for 907135003, check if your device has an access to internet.

MuhdSaifulnizam15 commented 3 years ago

Hi ozan,

Hi,

The error message 907135000 means the SDK is misconfigured, please check the instructions here and compare with your own configurations. As for 907135003, check if your device has an access to internet.

Hi,

May I know which error code message should I referred to? As I try to implement this in react native, is it from react-native guide or android guide

MuhdSaifulnizam15 commented 3 years ago

Anyways, It turned out that the reason why I am unable to retrieve the token is because I download the HMS Core from play store. Error prompted showing that unable to open HMS Core. After I reinstall the HMS Core from Huawei App Gallery, its working fine.

hds220 commented 3 years ago

@neilakoh you need add ### apply plugin: "com.huawei.agconnect" in app/build.gradle