6

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.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
Shadowself
  • 63
  • 4

2 Answers2

15

Try this

enter image description here

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

For more details,check Docs.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • I'm sorry, I update to version 5.3.0.301. it was deprecated in version 5.3.0.301, not version 5.0.4.302. And I know that AGConnectServicesConfig still exists in the pushSDK 5.3.0.301 version.I just found it was deprecated, So i want to find new class to substitute for it.how can i get app_id in version 5.3.0.301? If there is nothing to substitute for it, why you set it deprecated. Otherwise your demo is still version 5.0.4.302,I suggest updating to the newest version。Thank you. – Shadowself Jun 09 '21 at 08:23
  • hi@Shadowself, i updated my answer,you can try that. – zhangxaochen Jun 10 '21 at 02:01
3

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.

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32