More information, you can visit HUAWEI Developer Forum.
Complex self-networking, occasional long-tail latency, and network connection failures are preventing your game from earning more. Nearby Service will solve these problems with its nearby point-to-point (P2P) direct connection technologies.
{
"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"
}
Nearby Service has a technological edge in the following gaming scenarios:
Uses Bluetooth and Wi-Fi to discover devices. After integrating Nearby Service, your game can automatically search for nearby users who are also in the game without manual intervention.
Selects the best networking and transmission modes automatically. Nearby Service supports P2P, star, and mesh topologies and allows devices to connect to each other through Wi-Fi P2P without connecting to the same AP.
Uses Huawei-developed transmission protocols featuring high bandwidth, low latency, and high stability and reliability to transmit data.
App Development
An open-source game named Snake Land on GitHub is available for us to implement network communications using Nearby Service to support multi-player gaming. Snake Land originally uses the open-source framework KryoNet to implement the network communication layer. KryoNet supports only interconnection between mobile phones connected to the same router. After Nearby Service is integrated, nearby mobile phones can connect to each other unconditionally.
Getting Started
To integrate HUAWEI Nearby Service, you must complete the following preparations:
Configure app information in AppGallery Connect.
Enable HUAWEI Nearby Service.
Integrate the HMS Core SDK.
Configure obfuscation scripts.
For details, please refer to Getting Started.
How Can I Use Nearby Service
First, let's compare the APIs of KryoNet and Nearby Service.
API functions of Nearby Service and KryoNet are the same. Therefore, we only need to replace the APIs of KryoNet with those of Nearby Service and convert parameters based on the parameter type differences.
Permission Application
Nearby Service involves operations such as Bluetooth discovery and Wi-Fi hotspot creation. Therefore, you need to apply for some permissions from the user.
The sample code is as follows:
Code:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Building, Loading, and Debugging the App
After configuring the previous code, build your app, generate an APK file, and install it on the prepared phone running Android 8 or later for debugging. For details about the development procedure, please refer to Codelab.
Testing Your App
One party taps Create a Game, and the other party taps Join a Game to start mutual discovery. After one another is discovered, tap GO! to start the game. Swipe on the screen to control the direction of the green snake and get more food. The snake will fail if its head hits an obstacle.
If you are interested in the implementation details, download the source code from GitHub:
https://github.com/HMS-Core/hms-nearby-demo/tree/master/NearbyGameSnake
Conclusion
Using Nearby Connection, you can implement the following functions for your app:
1. Local multi-player gaming: Players can connect to each other's device flexibly and enjoy a smooth gaming experience enabled by low-latency (less than 50 ms), stable, and reliable data transmission.
2. Offline file transfer: Files can be transferred at a speed of up to 80 Mbit/s without consuming any mobile data.
If you are interested and want to learn more, check our development guide at
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/introduction-0000001050040566
Thank you very much
very useful article
Related
More information about this, you can visit HUAWEI Developer Forum
{
"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"
}
DStv Now is an entertainment app developed by Multichoice for the African market. Users can use it on a wide range of devices encompassing mobile devices, set-top boxes (STBs), game consoles, desktop computers, and smart TVs anytime, anywhere. DStv Now is dedicated to providing secure and reliable digital video content to both individual and family users.
It partners with HUAWEI AppGallery to build more secure and smoother video playback experience for Huawei device users, enabling users to entertain themselves anytime and anywhere. On DStv Now, Huawei device users can download live TV programs for offline playback, find their favorite TV series, movies, and sports events, and choose from local and international channels covering entertainment, news, music, lifestyle, and more.
HUAWEI AppGallery can provide featured and abundant global and local apps for about 650 million Huawei device users in over 170 countries and regions. Multichoice has always been bearing privacy protection and app security in mind when designing, developing, and operating DStv Now, dedicated to providing secure services for users.
DStv Now Integrated AppGallery Connect Safety Detect
Users are concerned about app security, and therefore it is significant for developers to ensure that their apps are secure and reliable. DStv Now is a typical entertainment app released on HUAWEI AppGallery. By leveraging the powerful capabilities of AppGallery Connect Safety Detect, its security has been improved greatly.
Safety Detect is a multi-dimensional open security detection service launched by HUAWEI AppGallery Connect. It detects system integrity, app security, malicious URLs, and fake user accounts, helping quickly build security for diverse apps including entertainment, finance, game, social, and shopping apps.
According to the feedback from the DStv Now's engineering leader, both the video playback experience and security of DStv Now have been improved since the integration with AppGallery Connect Safety Detect.
Safety Detect works in the following scenarios for DStv Now:
1. A user starts watching a video.
2. A user registers a device to allow video playback on this device.
3. A user downloads video content for offline playback.
Advantages:
The engineering leader of DStv Now said that "Using Safety Detect has helped with security and to gain assurance that our clients are using our app on certified devices. This helps root out piracy and assurance that streaming and video playback is being done on devices that are approved by our content providers. It also helps with ensuring a smooth user experience as we develop our features based on certified devices without the worry of catering to user modified devices."
In addition, DStv Now also leveraged HUAWEI AppGallery Connect Advanced Analytics to better understand user requirements, optimize functions, and provide users with more diversified and refined video content and higher-quality services. As one of the top three app stores in the world, HUAWEI AppGallery has an MAU of 460 million and looks forward to working with more global developers to provide secure and high-quality services for users in over 170 countries/regions around the world.
To download DStv Now, visit AppGallery now. For more information, please visit::
https://consumer.huawei.com/en/mobileservices/appgallery/
HMS vs. GMS- Gaming with Nearby Service
As a part of the HMS service suite for developers, Huawei offers Nearby Service. This service takes advantage of WiFi, Cellular and Bluetooth connections to provide users with scenario-based data transmission. This is what developers use to allow their users to conveniently interact with people and things nearby. Huawei uses its proprietary nStack technology to enable high-performance communication over a short distance. This allows for fast files transfers, communication, and collaboration.
How Nearby Service Enhances the Gaming Experience
To play games with a friend remotely, your phone will use your standard internet connection. If you want to play a game with a friend that is within your vicinity, nearby services can use a direct connection to make this a much better experience.
For users without cellular or WiFi data connections, they'll be able to use nearby service to continue to enjoy multiplayer gaming.
Huawei's comprehensive development guides can help you implement nearby service into your app, so your users can take advantage of local multiplayer gaming. These guides are easy to understand, and will quickly get you headed in the right direction for this service.
{
"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"
}
If you're looking for inspiration on how nearby service can be used in your app, you should look at Huawei's sample codes. These sample codes will show you different ways in which this service can be used to improve your app.
Huawei's HMS APIs are designed to provide you with a simple development process. You will not have to deal with underlying networking details, and you can just focus on your app's development.
HMS Nearby Services vs. GMS Nearby Connection
With the development of Nearby Service, Huawei is able to provide a much faster and more reliable service than the GMS Nearby Connection. HMS offers a complete open-source solution with kits available for many different aspects of your app development. Huawei has a strong development team and dedicates a lot of resources to help developers implement their services.
Read more: How to use HUAWEI Nearby Service to Develop a Business Card Exchange Function for APP
HMS vs. GMS- Transferring Files with Nearby Service
As a part of the HMS service suite for developers, Huawei offers Nearby Service. This service takes advantage of WiFi, Cellular and Bluetooth connections to provide users with scenario-based data transmission. This is what developers use to allow their users to conveniently interact with people and things nearby. Huawei uses its proprietary nStack technology to enable high-performance communication over a short distance. This allows for fast file transfers, communication, and collaboration.
One of the primary functions of nearby services is to allow the transfer of large files to another phone. This doesn't require any sort of internet connection, as your phone will be able to use WiFi to directly connect to the nearby device. All transfers are made through an https connection, ensuring a secure transfer.
Huawei's comprehensive development guides can help you implement nearby service into your app, so your users can take advantage of local multiplayer gaming. These guides are easy to understand, and will quickly get you headed in the right direction for this service.
{
"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"
}
If you're looking for inspiration on how nearby service can be used in your app, you should look at Huawei's sample codes. These sample codes will show you different ways in which this service can be used to improve your app.
Huawei's HMS APIs are designed to provide you with a simple development process. You will not have to deal with underlying networking details, and you can just focus on your app's development.
HMS Nearby Services vs. GMS Nearby Connection
When using Huawei's nearby service for file transfer, users are able to achieve up to 50mbps file transfer speed. This is faster than the GMS nearby connect service, which will max out at 40mbps. This faster data transfer speed is made possible by Huawei's proprietary nStack technology.
Faster speeds mean that the HMS solution will be better for creating apps that allow users to transfer large file sizes. Sending movies, music, documents, or other large files will now be as easy as transferring them to a nearby phone. A good example of an app that benefits from nearby service is Zapya. This popular file transfer app uses HMS nearby services to let you send large files to phones that are close by. Using the app, you'll be able to transfer a 3GB file in only 1 minute. You can rely on efficient and secure file transfers.
File transfer speed isn't the only area where HMS is able to out-perform GMS. The node discovery speeds also come into play here. This is where a user will scan for a nearby phone, and wait for results. Nearby service has faster discovery time based on Huawei-developed protocols.
Read more: How to use HUAWEI Nearby Service to Develop a Business Card Exchange Function for APP
The Huawei Nearby Service, an important feature of HMS Core, provides your App with high-speed transmission capabilities over short distance without Internet based on technologies such as Bluetooth and Wi-Fi, and the transmission speed can be in excess of 60MBps.
Nearby Service allows you to share audio and video in the App, lets users bid farewell to the trouble of computer transfer and saves wasted traffic through Internet transmission or download.
And the open source simple APIs allow you to easily integrate the transmission function to enhance product competitiveness and user experience.
Benefits of HUAWEI Nearby Service
High-speed transmission: Utilizes Huawei-developed nStack X protocol stack to achieve a 30% higher transmission rate, in excess of 60MB/s.
Automatic network configuration: Selects the optimal network mode(Wi-Fi hotspot, Wi-Fi P2P, etc.), without the need for manual configuration.
Quick integration: File transmission APIs can be integrated with just two lines of code (please refer to the open source code below.)
Full Android platform support: All terminals running Android 5.0 or later are supported, with Windows and iOS coverage planned for the near future.
Success Stories
WlanPlay, a popular video player developed by iQIYI, provides users with high-quality video play and sharing experiences. With HUAWEI Nearby Service, WLanPlay greatly increases the transmission speed in excess of 60MBps and allow users to enjoy zero-traffic, high-speed audio and videos sharing function to enhance product competitiveness.
{
"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"
}
You can use the open source code to quickly integrate NearbyService by calling 2 APIs to achieve file transmission
If you need to customize the data transmission mode, please refer to the detailed API guidance:
Nearby Service - In-App Data Sharing and Messaging Services - HUAWEI Developer
Sample code for customized data transmission
If you have any needs or suggestions, please contact: [email protected]
Sherlock F said:
You can use the open source code to quickly integrate NearbyService by calling 2 APIs to achieve file transmission
Click to expand...
Click to collapse
Hi, Bro. The link of open source code in your article should be updated here. I have updated here. Open source code: https://github.com/HMS-Core/hms-nearby-demo/tree/master/NearbyFileTransfer
AppGallery Connect provides not only full-lifecycle app services, but cross-platform service capabilities as well. By providing easy-to-use cross-platform SDKs and REST APIs, it enables you to develop apps using most of mainstream development languages.
AppGallery Connect services can be used for Android, web, and quick apps with cross-platform framework, including Flutter, Cordova, and React Native. What's more, Cocos also encapsulates Android SDKs of AppGallery Connect services, facilitating the development of high-quality games.
Build services allow you to quickly release apps, free you from maintenance, and reduce service costs, improving app development efficiency. Based on the model of Acquisition, Activation, Retention, Revenue, and Referral (AARRR), grow services are equipped to help you conduct refined operations throughout the lifecycle. Quality services span the entire process from app development to app release. By flexibly using these services, you can obtain crucial insights into your app's issues, monitor app performance, improve app quality, and enhance overall user experience.
{
"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"
}
1. Supports platforms including Android, web, and quick app.
AppGallery Connect services support all Android devices and can be easily integrated to other platforms. All you need to do is add the plugins and SDKs to your code. For details about integration, please refer to Getting Started with Android. To develop a specific service, refer to its documentation.
If you are developing a web app or quick app, please refer to Getting Started with Web or Installing the Development Tool, respectively.
2. Support cross-platform frameworks including Cordova, Flutter, and React Native.
An app built based on a cross-platform framework does not require separate coding for each platform, but instead will run efficiently on multiple platforms after one-time coding. That's why cross-platform apps have become such a hot development trend. Currently, Auth Service, Remote Configuration, and Crash support the Cordova, Flutter, and React Native frameworks. All you need to do is integrate the AppGallery Connect cross-platform framework plugins into your development environment before using these services. For details about integration, please refer to Getting Started with Flutter, Getting Started with React Native, and Getting Started with Cordova, respectively.
3. Support cross-platform game engines.
You can integrate AppGallery Connect build (Auth Service, Cloud Functions, Cloud DB, and Cloud Storage), quality (Crash and APM), and grow (Remote Configuration, App Linking, and App Messaging) services into a game developed using Cocos and other game engines. For details, please refer to Cocos official materials.https://service.cocos.com/document/en/agc-apm.html
These services help you with building high-quality games, growing your player base and improving player experience.
AppGallery Connect provides apps with access to a massive pool of devices, while offering developers versatile services that meet all conceivable needs. In the future, more cross-platform service capabilities will be supported to suit diversified application scenarios, providing more high-quality apps and services for Huawei users, and unique opportunities for your business grow. If you have any suggestions, please send an email to [email protected].
You can also access a substantial amount of sample code via GitHub.https://github.com/AppGalleryConnect