当前位置:网站首页>Deeplink realizes the payment function of Huawei's out of application goods

Deeplink realizes the payment function of Huawei's out of application goods

2020-12-08 09:53:55 Huawei Developer Forum

background

The project team hopes to access Huawei's out of application payment function , Click commodity payment on the game details page of Huawei application market , adopt DeepLink Link from Huawei application market to this game payment details page , Delivery of payment goods ID Make a purchase .

Reference documents :https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/appgallerykit-devguide-game#h1-1589804284330

For better access , Here we do a functional verification , Share it with you .

Realization way

1. manifest in Activity To configure

stay Activity Middle configuration intent-filter filter

<data android:scheme="agpms" android:path="/product/pay" android:host="com.sxx.huawei"/>

The request address after splicing is :agpms://com.sxx.huawei/product/pay

Link format requirements are as follows file Format ( If not in this format , Marketing address on the shelf audit will not pass )

 Insert picture description here

Configuration is shown in figure :

 Insert picture description here

2. Jump code implementation ( This is to open from an external application deeplink Address )

In theory, it should be applied in Huawei market APP To open this address , But at present, because our game is not on the shelves , And the market of Huawei is applied APP There is no such test environment on the side , So to see the effect , I've got another app of my own .

Intent intent = new Intent();
 intent.setAction("com.google.open02");
 intent.addCategory("android.intent.category.DEFAULT");
 intent.setData(Uri.parse("agpms://com.sxx.huawei/product/pay?producid=TestProduct503"));
 startActivity(intent);

agpms://com.sxx.huawei/product/pay?producid=TestProduct503
The parameter carried after the question mark is usually key=value&key1=value1 Format .

The code screenshot is as follows :

 Insert picture description here

Code above : With only one field, it is producid

3. Jump to the payment details page and analyze deeplink The field parameters carried in the address

  • If the details page is not opened before the jump , You need to in Activity Life cycle onCreate In order to get intent Object parsing data.
  • If the details page is not opened before the jump , You need to in Activity Life cycle onCreate In order to get intent Object parsing data.

The code screenshot is as follows :

 Insert picture description here

The code above gets data Goods in data ID after , You can launch HMS SDK The payment interface pulls up the payment page .

FAQ

Deeplink After the relevant configuration is completed, it still cannot be opened ?

It is usually due to the address in the splicing when jumping scheme,host,path And the inconsistency in the configuration , Refer to the above document for self inspection .


Link to the original text :https://developer.huawei.com/consumer/cn/forum/topic/0204405033183830230?fid=18

The original author :AppGallery Connect

版权声明
本文为[Huawei Developer Forum]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/202012080953224942.html