Develop Your Bicycle Rental App in 6 Easy Steps | Part III

Healthy Cycling App: Geofence feature of Location Kit and App Messaging

Feyza Ürkut
Huawei Developers
5 min readJan 27, 2023

--

Develop Your Bicycle Rental App in 6 Easy Steps | Part III

Introduction

Hi, everyone🎈

In this series of articles, I will explain you how we can develop a Bike Rental Application in 6 easy steps using Huawei Services. In the last article of the series, I will talk about the Geofence Feature and App Messaging, which makes a difference to our application. Let’s complete our application with the steps of specifying surprise areas and informing the user!

Content

Introducing the Healthy Cycling App

1- Add Dependencies & Permissions for Location Kit and App Messaging

2- Using Geofence Feature of Location Kit for Specifying Surprise Areas

3- Using App Messaging to Inform the User for Surprises Discount

Conclusion

References

Healthy Cycling App

The Healthy Cycling is a sample application with which you can perform bicycle rental operations and see your weekly progress with some data like total distance, time, calorie etc.

With this application, I aim to encourage people to use bicycles that are healthy and environmentally friendly.

The mix of bicycle rental and exercise application. Reduce air pollution and live healthily!

Some of the HMS Kits and Services that we use in our project, which are among the capabilities provided by HUAWEI Mobile Services for efficient development, are as follows:

  • Auth Service
  • Map Kit
  • Location Kit
  • Scan Kit
  • IAP
  • Health Kit
  • Push Kit
  • App Messaging

The Android technologies we use in this project, which we are progressing with MVVM architecture, single activity multiple fragments approach and clean code principles, are as follows:

Healthy Cycling: All screenshots of the app

1- Add Dependencies & Permissions for Location Kit and App Messaging

  1. Create an app in App Gallery Connect and integrate the App Gallery Connect SDK into your app. For details, you can follow the preparations codelab: Preparations for Integrating HUAWEI HMS Core
  2. Enable Location Kit in Manage APIs bar. You can follow the steps to add the necessary permissions in the first article of the series.
AppGallery Connect: Enable Location Kit

3. Go to Grow>App Messaging, click Use Now.

AppGallery Connect: Enable App Messaging
AppGallery Connect: Warning for enabling Analytics Kit

4. Go to HUAWEI Analytics>Overview>Project Overview. On the HUAWEI Analytics page, click Enable HUAWEI Analytics to create custom event.

AppGallery Connect: Enable Analytics Kit

5. Add build dependencies to the dependencies block.

2- Using Geofence Feature of Location Kit for Specifying Surprise Areas

  1. Create a GeofenceService object and dynamically register GeoFenceBroadcastReceiver through PendingIntent. A broadcast message will be sent when the geofence is triggered.

2. Register a broadcast receiver for the geofence service. When detecting a geofence trigger event, the system broadcasts a notification to the user using PendingIntent.

3. With createGeofence() method, create a geofence instance with manuel data. Construct a request to add a geofence by passing PendingIntent, and process the response to the geofence addition request.

3- Using App Messaging to Inform the User for Surprises Discount

Create Custom Event with Analytics Kit

  1. Under HUAWEI Analytics > Management > Events, after pressing the New > Custom buttons, you can create a custom event by entering the required information. We created a custom event called ‘GeofenceSuccess’.
AppGallery Connect: Creating new event.
Creating new custom event.

Create an In-App Message

  1. Go to Grow > App Messaging and click New.
AppGallery Connect: Creating new in-app message.

2. Set the name, description, message style and content, including the image and button settings, and click Next. We are using Modal layout for our project; you can see the preview in the next screenshot. You can also customize all these features for your own app.

Editing an in-app message.
Preview for the in-app message.

3. While we set the sending time, we must choose the trigger event to display the message. In this project, we use the custom event that we created.

Schedule for the in-app message.

4. Finally, you can use the custom event to trigger in-app message.

Output for Geofence & App Messaging Features
Output for Progress & Payment Process

Conclusion

In this project, we have designed a scenario that will determine surprise locations in the bicycle rental app and inform the user that the user will earn surprise discounts by entering that area. To realize this scenario, we used the Geofence Feature of the Location Kit and the custom event and App Messaging service.
I tried to explain all the steps in this article, I hope it was a useful resource for you✨

With this latest article, we have now completed the series, our bike rental application, which I have been trying to use current Android approaches and clean code techniques🥳 Good work to everyone!

References

--

--