Shadowself
Shadowself

Reputation: 63

Class "AGConnectServicesConfig" is deprecated in com.huawei.hms:push:5.3.0.301

When I updated the pushSDK to the version "5.3.0.301", I found AGConnectServicesConfig was deprecated. I want to know what is the substitute for it. How can I get app_id in the new version? I used to get app_id like this:

  String appId = AGConnectServicesConfig.fromContext(context).getString("client/app_id");

How can I get it when I update?

I have found the source code, but I can't find any substitute for this.

Upvotes: 6

Views: 2150

Answers (2)

Halil Ozel
Halil Ozel

Reputation: 3322

My answer is:

Step-1 : Dependency version was updated.

    implementation 'com.huawei.hms:push:6.1.0.300'
    classpath 'com.huawei.agconnect:agcp:1.6.0.300'

Step-2 : This was changed.

AGConnectOptionsBuilder().build(this@MainActivity)
                    .getString("client/app_id")

It's worked.

Upvotes: 3

zhangxaochen
zhangxaochen

Reputation: 34017

Try this

enter image description here

 String appId = new AGConnectOptionsBuilder().build(MainActivity.this).getString("client/app_id");

For more details,check Docs.

Upvotes: 15

Related Questions