QUIZ MANIA GAME Featuring Huawei In App Purchase Kit & Ads Kit - Huawei Developers

This article is originally from HUAWEI Developer Forum
Forum link: https://forums.developer.huawei.com/forumPortal/en/home​
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Back in the 90’s, it was a revolutionary to have your own website and putting an advertisement in the website was the only source of revenue. But today as space matures, it’s essential for brands to have a clear strategy to monetize their mobile presence. Some companies charge their users before downloading their apps. Others depend on in-app advertising as their sole revenue stream. But, for a lot of brands, their mobile monetization strategy relies entirely (or some part) on In App Purchase. To summarise, when a customer spends money within a mobile app, that’s an in-app purchase.
To make easier for users to make payments and developers to focus solely on app innovation, Huawei provided us with an extraordinary kit i.e. HMS Core In App Purchase (IAP) Kit.
HMS In App Purchase helps developers in variety of situation to earn revenue such as paying for access to a dating app’s special features, subscribing to a streaming music app’s premium tier, buying more gold bars in games etc.
DEMO
Check out the demo created by me to make you understand, How HMS Core In App Purchase works.
Today, in this article we are going to see how to integrate HMS In App Purchase in a simple yet complex Quiz Game app. To be honest everything can’t be covered in a single article. So, I have prepared a sample project and will provided the code on Github soon. I also tried making it simple as much as possible so that every beginner can understand it.
Settings Needed
1) First we need to create an app or project in the Huawei app gallery connect.
2) Provide the SHA Key and App Package name of the android project in App Information Section.
3) Provide storage location in convention section under project setting.
4) Enable In-App Purchase setting in Manage APIs section.
5) After completing all the above points we need to download the agconnect-services.json from App Information Section. Copy and paste the json file in the app folder of the android project.
6) Copy and paste the below maven url inside the repositories of buildscript and allprojects respectively (project build.gradle file)
Code:
maven { url 'http://developer.huawei.com/repo/' }
7) Copy and paste the below class path inside the dependency section of project build.gradle file.
Code:
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
8) Copy and paste the below plugin in the app build.gradle file
Code:
apply plugin: 'com.huawei.agconnect'
9) Copy and paste below library in the app build.gradle file dependencies section.implementation 'com.huawei.hms:iap:4.0.2.300'
10) Put the below permission in AndroidManifest file.
Code:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
11) Now Sync the gradle.
Essential Requirement
Become a Merchant
We need to be a merchant in order to use HMS IAP Kit. Also after making your account as merchant, it will take 1 or 2 business days for verification.
Steps:
a) Login to Huawei Developer website.
b) Go to console.
c) Under Settings you will find Merchant Service as shown below:
d) Provide our bank details information here as shown below:
e) Provide our tax related information here as shown below:
f) Finally click submit to save the record for verification.
Need Public Key
We need a public key which is used for subsequent payment signature verification and a parameter for configuring the subscription notification URL.
b) After the configuration is successful, we will be able to see a public key. This public key we will use later.
Steps:
a) On the Develop tab page, go to Earning > In-App Purchases from the navigation tree on the left and click Settings. If this is the first time we configure the IAP service, a dialog box is displayed for you to sign the agreement.
Need Sandbox Account
We need sandbox account in order to test HMS IAP. During app development and testing, we can test product payments with a test account in the sandbox environment. During the testing period, when a purchase is initiated by the test account, the Huawei IAP server will identify the test account and directly process a successful payment, without real payments made.
Steps:
a) Go to AGC and select users and permissions.
b) Select Test account as shown below:
c) Click Add button to add test account as shown below:
d) After this a testing account is added. Make sure to add account which is used in Huawei devices to login.
This is not the end. For full content, you can visit https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201255229704010231&fid=0101187876626530001

This app is a great example for how Huawei Ads Kit can be used to monetize your app.

Related

Initiate payment using IAP(Part 1)

I have written series of article on Quick App. If you are new to Quick App refer my previous articles.
Quick App set up
A Novice Journey Towards Quick App ( Part 2 )
A Novice Journey Towards Quick App ( Part 3 )
Introduction
In App Purchase makes user to make online payment. In order make online payment in quick app let’s see how to integrate the IAP in Quick App.
Follow the steps
Step 1: Sign in to AppGallery Connect and select My projects.
Step 2: Select the project which you need to enable the service.
Step 3: Click the Manage API tab, Enable In-App purchase.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Above screen will show when Merchant service is not enabled. If you don’t have Merchant account follow the Enable Merchant service.
Step 4: Sign in to HUAWEI Developer. Click Console.
Step 5: Click App Services in the navigation bar on the left and select HUAWEI IAP.
Step 6: From the product list, find the app for which the HUAWEI IAP service will be configured. Then, click Update.
Step 7: Configure HUAWEI IAP service information.
Callback Address: can be modified after configuration. Ensure that the app's callback address can be visited. The value can contain a maximum of 255 characters and cannot end with a backslash (\). The callback address can be a multi-level domain name, where special characters such as underscores(_) cannot be contained. Note that callback address is not required for apps without a server.
Signed Certificate: Navigate to Tools > Certificate
Make sure you copy the generated certificates to sign > debug folder from the release folder.
Step 8: After completing the configuration, click Next, and then Submit.
Enable Merchant service
We need to be a merchant to make use of In-App Purchase in Quick App.
Note: Once your account becomes merchant, it takes 2-3 business day for verification.
Follow steps to enable merchant service
Step 1: Sign in to HUAWEI Developer. Click Console.
Step 2: In Settings, you will find Merchant Service as shown below.
Step 3: Enter the details in Bank information, as shown below.
Step 4: Enter details in Tax information node, as shown below.
Step 5: Click Submit to save the record for verification.
Create test account
Need sandbox account to test the IAP in quick App. During application development and testing we can use the sandbox account to make payment. During the testing period, when a purchase is initiated by the test account, the Huawei IAP server will identify the test account and directly process a successful payment, without real payments made.
Follow the steps to enable the sandbox account
Step 1: Navigate to AGC and select users and permissions.
Step 2: Select Test account, as shown below.
Step 3: Click Add button to add Test account, as shown below.
Huawei In-App purchase information
1. Sign in to HUAWEI Developer. Click Console.
2. Click App Services in the navigation bar on the left and select HUAWEI IAP.
3. Click the quick app for which HUAWEI IAP Service has been configured.
4. Find HUAWEI IAP Service parameters in the Service Info section.
APP ID: unique ID assigned by HUAWEI Developer to an app. Please store it properly for future use.
Payment ID: Used to configure the merchantId parameter in the development process.
Private key: RSA private key, used to sign the requested parameters when a developer's app invokes HMS SDK payment method.
Public key: RSA public key, used to verify the signature when a developer's app receives payment results from HMS SDK.
Result
Coming soon in next article.
Conclusion
In this article, we have learnt how integrate IAP in Quick App. In upcoming article I will continue the IAP adding products and product details and making payment online.
Reference
In-App Purchase official document
Do we need to be enterprise developer in order to work with HMS IAP ?

Huawei App Linking : Increase views for your in-app content

Introduction
App Linking or deep linking is a technology which enable businesses to provide ease of access for their potential services.
Deep links are links which re-direct users directly to a specific app or application feature instead of a website or store.
They are used to re-direct users straight to in-app locations, saving the users time and energy.
Deep linking does this by specifying a custom URL scheme (iOS Universal Links) or an intent URL (on Android devices) that opens your app if it’s already installed. Deep links can also be set to direct users to specific events or pages.
Huawei App Linking leverage developers/users to create cross platform links which can work as defined and can be distributed via multiple channels to users.
When the user taps the link, it will be re-directed to the specified in-app content.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Huawei App Linking has multiple functions:
1. Support for deferred deep links
2. Link display in card form
3. Data statistics
Huawei App Linking supports the link creation in multiple ways:
1. Creating a link in AppGallery Connect
2. Creating a link by calling APIs on the client
3. Manually constructing a link
Use Case
There could be multiple use cases for this capability, however I will throw some light on a use case which is most commonly adapted by the applications with complex UX and high transmission between different in-app pages.
In this scenario one application shares the link between counter applications to re-direct to in-app content of a third application.
We will have an application which shares the app link at one end to another (It can be a simple chat platform capability). At the receiver end, user can click on the link and directly navigate to the specific in-app content.
Working
Following are the steps to develop this scenario
1. Development of news application which will be deployed locally.
2. Development of share application which will be deployed locally.
3. Integration of Huawei App Linking Api’s to receive the link and re-direct to the in-app content of news app.
4. Enabling the App linking service in AppGallery Connect.
5. Creating deep link through AppGallery Connect.
Development Overview
1. Must have a Huawei Developer Account
2. Must have Android Studio 3.0 or later
3. Must have a Huawei phone with HMS Core 4.0.2.300 or later
4. EMUI 3.0 or later
Software Requirements
1. Java SDK 1.7 or later
2. Android 5.0 or later
Preparation
1. Create an app or project in Android Studio.
2. Create an app and project in the Huawei AppGallery Connect.
3. Provide the SHA Key and App Package name of the project for which you want the App Linking to be done (Example: News application)
4. Download the agconnect-services.json file and paste to the app folder of your android studio.
Integration
Add below to build.gradle (project)file, under buildscript/repositories and allprojects/repositories.
Code:
Maven {url 'http://developer.huawei.com/repo/'}
Add below to build.gradle (app) file, under dependencies to use the App Linking SDK.
Code:
dependencies{
// Import the SDK.
implementation 'com.huawei.agconnect:agconnect-applinking:1.4.1.300'
}
News Application
News application is developed with multiple content and complex UX to show the capability of the Huawei App Linking.
I will highlight some of the important code blocks for this application.
Main Activity
This activity is the entry point for the application which will have the navigation tab to handle the multiple news categories.
Also, it receives the App Link, read it and re-direct it to the corresponding content.
Creating a link in AppGallery Connect to directly open the Science tab for the News Application through a link
1. Login to AppGallery Connect.
2. Choose My Projects > NewsWorld(App Linking).
3. Choose > Growing > App Linking>Enable now
More details, you can visit https://forums.developer.huawei.com/forumPortal/en/topic/0204412564790410224

How to Build Hotel booking application using HMS Kits-part-1(Account & Ads Kit)

Introduction
This article is based on Multiple HMS services application. I have created Hotel Booking application using HMS Kits. We need mobile app for reservation hotels when we are traveling from one place to another place.
In this article I have implemented Account kit and Ads Kit. User can login through Huawei Id.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Flutter setup
Refer this URL to setup Flutter.
Software Requirements
1. Android Studio 3.X
2. JDK 1.8 and later
3. SDK Platform 19 and later
4. Gradle 4.6 and later
Steps to integrate service
1. We need to register as a developer account in AppGallery Connect
2. Create an app by referring to Creating a Project and Creating an App in the Project
3. Set the data storage location based on current location.
4. Enabling Required Services: Account and Ads Kit.
5. Generating a Signing Certificate Fingerprint.
6. Configuring the Signing Certificate Fingerprint.
7. Get your agconnect-services.json file to the app root directory.
Development Process
Create Application in Android Studio.
1. Create Flutter project.
2. App level gradle dependencies. Choose inside project Android > app > build.gradle.
Code:
apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
Root level gradle dependencies
Code:
maven {url 'https://developer.huawei.com/repo/'}
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
Add the below permissions in Android Manifest file.
Code:
<manifest xlmns:android...>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
</manifest>
3. Refer below URL for cross-platform plugins.
https://developer.huawei.com/consum...y-V1/flutter-sdk-download-0000001051088628-V1
4. On your Flutter project directory find and open your pubspec.yaml file and add library to dependencies to download the package from pub.dev. Or if you downloaded the package from the HUAWEI Developer website, specify the library path on your local device. For both ways, after running pub get command, the plugin will be ready to use.
Code:
name: hotelbooking
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
shared_preferences: ^0.5.12+4
bottom_navy_bar: ^5.6.0
cupertino_icons: ^1.0.0
provider: ^4.3.3
huawei_ads:
path: ../huawei_ads/
huawei_account:
path: ../huawei_account/
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/images/
5. We can check the plugins under External Libraries directory.
6. Open main.dart file to create UI and business logics.
Account kit
Account kit allows users to login their applications conveniently, quickly and simple login functionalities to the 3rd party applications.
If you examine Account Kit’s Official Huawei resources on internet, it also appears that they imply the simplicity, fastness and security. We can make use of following observation to understand where this fastness and simplicity is originated.
Service Features
Quick and standard
Huawei Account Kit allows you to connect to the Huawei ecosystem using your HUAWEI ID from a range of devices. This range of devices is not limited with mobile phones, you can also easily access applications on tablets, wearables, and smart displays using Huawei ID.
Massive user base and global services
Huawei Account Kit serves 190+ countries and regions worldwide. Users can also use HUAWEI ID to quickly sign in to apps. For details about supported regions/countries, please refer here from official documentation.
Secure, reliable, and compliant with international standards
Complies with international standards and protocols (such as OAuth2.0 and OpenID Connect), and supports two-factor authentication to ensure high security.
Integration
Signing-In
To allow users securely signing-in with Huawei ID, you should use signIn method of HMSAccount module. When this method called for the first time for a user, a Huawei ID authorization interface will be shown Once signIn successful, it will return AuthHuaweiID object.
Code:
void _signInHuawei() async {
final helper = new HmsAuthParamHelper();
helper
..setAccessToken()
..setIdToken()
..setProfile()
..setEmail()
..setAuthorizationCode();
try {
HmsAuthHuaweiId authHuaweiId =
await HmsAuthService.signIn(authParamHelper: helper);
StorageUtil.putString("Token", authHuaweiId.accessToken);
Navigator.push(context,MaterialPageRoute(builder: (context) => HomePageScreen()),
);
} on Exception catch (e) {}
}
Signing-Out
signOut method is used to allow user signing-out from app, it does not clear user information permanently.
Code:
void signOut() async {
try {
final bool response = await HmsAuthService.signOut();
} on Exception catch (e) {
print(e.toString());
}
}
ADs kit
Nowadays, traditional marketing has left its place on digital marketing. Advertisers prefer to place their ads via mobile media rather than printed publications or large billboards, this way they can reach their target audience more easily and they can measure their efficiency by analyzing many parameters such as ad display and the number of clicks.
HMS Ads Kit is a mobile service that helps us to create high quality and personalized ads in our application. It provides many useful ad formats such as native ads, banner ads and rewarded ads to more than 570 million Huawei device users worldwide.
Advantages
1. Provides high income for developers.
2. Rich ad format options.
3. Provides versatile support.
1. Banner Ads are rectangular ad images located at the top, middle or bottom of an application’s layout. Banner ads are automatically refreshed at intervals. When a user taps a banner ad, in most cases the user is taken to the advertiser’s page.
2. Rewarded Ads are generally preferred in gaming applications. They are the ads that in full-screen video format that users choose to view in exchange for in-app rewards or benefits.
3. Native Ads are ads that take place in the application’s interface in accordance with the application flow. At first glance they look like a part of the application, not like an advertisement.
4. Interstitial Ads are full screen ads that cover the application’s interface. Such that ads are displayed without disturbing the user’s experience when the user launches, pauses or quits the application.
5. Splash Ads are ads that are displayed right after the application is launched, before the main screen of the application comes.
Huawei Ads SDK integration Let’s call HwAds.init() in the initState()
Code:
@override
void initState() {
super.initState();
HwAds.init();
}
Load Banner Ads
void loadAds() {
BannerAd _bannerAd;
_bannerAd = createAd()
..loadAd()
..show();
}
BannerAd createAd() {
return BannerAd(
adSlotId: "testw6vs28auh3",
size: BannerAdSize.s320x50,
adParam: new AdParam());
}
Load Native Ads
Code:
NativeAdConfiguration configuration = NativeAdConfiguration();
configuration.choicesPosition = NativeAdChoicesPosition.bottomRight;
Container(
height: 100,
margin: EdgeInsets.only(bottom: 10.0),
child: NativeAd(
adSlotId: "testu7m3hc4gvm",
controller: NativeAdController(
adConfiguration: configuration,
listener: (AdEvent event, {int errorCode}) {
print("Native Ad event : $event");
}),
type: NativeAdType.small,
),
),
Result
Tips & Tricks
1. Download latest HMS Flutter plugin.
2. The lengths of access_token and refresh_token are related to the information encoded in the tokens. Currently, access_token and refresh_token contains a maximum of 1024 characters.
3. This API can be called by an app up to 10,000 times within one hour. If the app exceeds the limit, it will fail to obtain the access token.
4. Whenever you updated plugins, click on pug get.
Conclusion
We implemented simple hotel booking application using Account kit and Ads kit in this article.
Thank you for reading and if you have enjoyed this article, I would suggest you to implement this and provide your experience.
Reference
Account Kit URL
Ads Kit URL
Read full article
Garrygb said:
Hi! Thank you for share this information. I tried to build apps for my business using HMS kits but unfortunately have some problems with the main code and I can't find where this code error. Perhaps, I will try to ask for help from professional apps developers.
Click to expand...
Click to collapse
Hi can you please explain which kit you integrated in your application ,can you explain detail so that i can able to help you out to fix your problems
I deleted all projects and start new.

Releasing Your Game on HUAWEI AppGallery via UDP

Releasing Your Game on HUAWEI AppGallery via UDP
Background
These posts outline the first steps required for developing a Unity game:
Unity Editor Installation and APK Packaging
How Can I Use the HUAWEI Game Service Demo Provided by Unity?
Initializing a Huawei Game and Implementing HUAWEI ID Sign-in Using Unity
How to Integrate Unity IAP for a Game to Be Released on HUAWEI AppGallery
Here, we have built an APK that provides a range of basic functions, such as payment and game sign-in. This post details the process for releasing the APK to HUAWEI AppGallery, walking you through each step in the process and showing the final effects.
Uploading the APK to UDP
UDP is short for Unity Distribution Portal. First, we’ll need to upload the generated APK as follows.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
The following UI information is displayed on the figure below.
UDP Initialization: The initialize API of UDP has been called in the game.
IAP Transaction: The purchase API of UDP has been called in the game.
The two APIs must be called and tested prior to the game’s release.
Completing the Necessary Configurations Prior to the Game’s Release
You can refer to the Unity official materials for reference:
https://distribute.dashboard.unity.com/udp/guideDoc/HUAWEI
I have registered as a Huawei developer account, and created game information in AppGallery Connect, and related information has been recorded (see this post). Therefore, I’ll only need to supplement the information that has not yet been completed.
After a successful release, the Publish page will display. Click Register your game with HUAWEI AppGallery.
In the displayed dialog box, click Next.
Then, in the following dialog box, click Link game to UDP.
After linking, the following page will display. In this case, we’ll need to fill in the game registration information by referring to the Unity materials.
Please note that when you obtain the PubKey field in the game registration information, if the following page is displayed in AppGallery Connect, you’ll need to click Settings to obtain the payment public key.
Set PubKey and privacyPolicy in the game information, and then click REGISTER. The page below will then display. You can see that the game is in Ready to publish state.
There are two options in the drop-down list on the right.
Repack Game: Unity only uses Huawei SDK to repack the uploaded APK.
Submit to Store: Unity repacks the APK, and uploads the repacked APK to AppGallery Connect for review.
Repacking and Testing Your Game
Here, Repack Game is recommended. You’ll need to test the functions of the APK repacked by Unity before submitting it to Huawei for review.
Click Download to download the successfully repacked game package.
If you encounter any issues during the self-test:
Here, I ran into some issues, so I deleted the original APK from the game information and re-submitted an APK for release. The new package is as follows.
Re-download the package, and continue the test until no problems are detected during the self-test.
If no issues are encountered during the self-test:
You can proceed to the next section.
Releasing Your Game on AppGallery, and Awaiting Huawei’s Review
If no issues are encountered during your self-test, upload the APK once again, and select Submit to Store. Unity will pack the app again, and submit it to Huawei for review. The app information and product information will also be synchronized to AppGallery Connect.
Note: In the past, I thought that after I clicked Repack Game and confirmed that the package is normal, I could submit the package to Huawei for review by clicking Submit to Store. However, in reality, I found that the game and product information did not display after I clicked Submit to Store, which required that I fill in the information again. Therefore, I wouldn’t recommend this option. The details are as follows:
1. The product and game information needs to be maintained in UDP and AppGallery Connect, respectively. You’ll need to fill in the information twice.
2. You won’t be able to view the game release status in each app store via UDP.
Therefore, this solution can be used as an alternative unless a problem that is hard to handle or is caused due to callback failure, occurs during the synchronization of information from UDP to AppGallery Connect.
After I clicked Submit to Store, two warnings were displayed, as shown below.
The first warning is related to the configuration of the SHA-256 certificate fingerprint. I previously completed the configuration in this post. Here, I can just ignore it.
The second warning indicates that the release time is not set. In this case, after my game is submitted to Huawei for review, it will be released immediately after being approved. Therefore, if you do not want your game to be automatically released right after being approved by Huawei, click Modify to set the release time. I’m ignoring this setting here.
You can see that the game has been submitted to AppGallery Connect for review.
After signing in to AppGallery Connect, you’ll be able to see:
1. On the app information page, Unity has synchronized the app information to AppGallery Connect.
2. On the product management page, Unity has synchronized product information to AppGallery Connect.
3. The game is under review.
Thus far, I have successfully released a game to AppGallery through Unity, and am in the process of awaiting Huawei’s review result.
To complete the release process outlined in this post, you’ll need to be familiar with the development and release process for Huawei games in Unity. For more details, you can refer to the following posts:
Unity Editor Installation and APK Packaging: https://forums.developer.huawei.com/forumPortal/en/topic/0204435788744370088?fid=0101187876626530001
How Can I Use the HUAWEI Game Service Demo Provided by Unity?: https://forums.developer.huawei.com/forumPortal/en/topic/0204451267476400094?fid=0101188387844930001
Initializing a Huawei Game and Implementing HUAWEI ID Sign-in Using Unity: https://forums.developer.huawei.com/forumPortal/en/topic/0202458249587900041?fid=0101188387844930001
How to Integrate Unity IAP for a Game to Be Released on HUAWEI AppGallery: https://forums.developer.huawei.com/forumPortal/en/topic/0201472979681270115?fid=0101188387844930001
thanks for sharing
shikkerimath said:
thanks for sharing
Click to expand...
Click to collapse
thanks for your liking.

Pygmy Collection Application Part 3 (Crash service)

Introduction
In my last article, I have explained how to integrate account kit finance application. Have a look into Pygmy collection application Part 1 (Account kit). And Integration of Huawei Ads kit have look into Intermediate: Pygmy Collection Application Part 2 (Ads Kit)
What is Huawei Crash service?
In this article, we will learn how to integrate Crash services of AppGallery in Pygmy collection finance application.
Huawei Crash is a realtime crash reporting tool that helps in tracking, prioritizing, and fix stability issues that compromise the quality of your app. Crashlytics also helps in troubleshooting and saves the debugging.
The AppGallery Connect Crash service provides a powerful lightweight solution to app crash problems. With the service, you can quickly detect, locate and resolve app crashes (unexpected exits of apps), and have access to highly readable crash reports in real time, without the need to write any code.
To ensure stable running of your app and prevent user experience deterioration caused by crashes, you are advised to monitor the running status of your app on each device, which is the key. The Crash service provides real-time reports, revealing any crash of your app on any device. In addition, the Crash service can intelligently aggregate crashes, providing context data when a crash occurs, such as environment information and stack, for you to prioritize the crash easily for rapid resolution.
Why do we need the crash service?
Although apps have gone through rounds the tests before release considering the large user base diverse device models and complex network environment. It’s inevitable for apps to crash occasionally. Crashes compromise user experience, users may even uninstall app due to crashes and your app is not going to get good reviews.
You can’t get sufficient crash information from reviews to locate crashes, therefore you can’t resolve them shortly. This will severely harm your business. That’s why we need to use the crash services in our apps to be more efficient.
How to integrate Crash Service
1. Configure the application on the AGC.
2. Client application development process.
1. Configure application on the AGC
Follow the steps
Step 1: We need to register as a developer account in AppGallery Connect. If you are already a developer ignore this step.
Step 2: Create an app by referring to Creating a Project and Creating an App in the Project
Step 3: Set the data storage location based on the current location.
Step 4: Generating a Signing Certificate Fingerprint.
Step 5: Configuring the Signing Certificate Fingerprint.
Step 6: Download your agconnect-services.json file, paste it into the app root directory.
Step 7: Enable Crash services.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Client application development process
Follow the steps.
Step 1: Create an Android application in the Android studio (Any IDE which is your favorite).
Step 2: Add the App level Gradle dependencies. Choose inside project Android > app > build.gradle.
Code:
apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
implementation 'com.huawei.agconnect:agconnect-crash:1.6.0.300'
// It is recommended that you integrate the APM SDK to further locate whether an app crash is caused by an app event or behavior such as ANR, launch, and network request.
Code:
implementation 'com.huawei.agconnect:agconnect-apms:x.x.x.xxx'
implementation 'com.huawei.hms:hianalytics:5.0.5.300'
Root level gradle dependencies.
Code:
maven { url 'https://developer.huawei.com/repo/' }
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
Step 3: Add permission in AndroidManifest.xml
XML:
<application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
</application>
Step 4: Initialize Crash Service activity or application class
Step 5: Build Application
Enable Crash Service
Java:
AGConnectCrash.getInstance().enableCrashCollection(true);
Test Crash service.
Java:
AGConnectCrash.getInstance().testIt(context);
Set User Id
Java:
AGConnectCrash.getInstance().setUserId("12345");
Set Log without log level
Java:
AGConnectCrash.getInstance().log("set info log.");
Set Log with Log Level
Java:
AGConnectCrash.getInstance().log(Log.WARN, "set warn log.");
Set custom Key pair value.
Java:
AGConnectCrash.getInstance().setCustomKey("mobileNumber", "Phone number is empty");
// Add a key-value pair of the string type.
AGConnectCrash.getInstance().setCustomKey("UserName", "Basavaraj Navi");
// Add a key-value pair of the boolean type.
AGConnectCrash.getInstance().setCustomKey("isFirstTimeUser", false);
// Add a key-value pair of the double type.
AGConnectCrash.getInstance().setCustomKey("doubleKey", 1.1);
// Add a key-value pair of the float type.
AGConnectCrash.getInstance().setCustomKey("floatKey", 1.1f);
// Add a key-value pair of the integer type.
AGConnectCrash.getInstance().setCustomKey("intKey", 0);
// Add a key-value pair of the long type.
AGConnectCrash.getInstance().setCustomKey("longKey", 11L);
Record Exception
Java:
SimpleDateFormat format = new SimpleDateFormat(PygmyConstants.DOB_FORMAT);
try {
Date date = format.parse(dob);
customerEntity.setDateOfBirth(date);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
AGConnectCrash.getInstance().recordException(e);
}
Result
Tips and Tricks
Make sure you added agconnect-service.json file.
Add internet permission in AndroidManifest.xml.
You can also download the crash reports.
Conclusion
In this article, we have learnt what the Crash service is. And how to integrate the crash service. How to record log with log level and without log level. And also we have learn how to record exception.
Reference
Huawei Crash Service
Thanks for sharing!!!

Categories

Resources