Intermediate: OneSignal In-App Messages APIs Integration in Xamarin (Android)

In this article, I will create a demo app along with the integration of OneSignal In-App Messages APIs which is based on Cross platform Technology Xamarin. It provides to send specific messages when user are using application and developer can target users/auditions for specific notification.

Manoj Kumar
4 min readJun 25, 2021

OneSignal Service Introduction

OneSignal’s In-App Messages are highly customizable pop-up modals that any subscribed or unsubscribed Mobile App user can receive when they are inside your app.

Single SDK- User will not need to manage separate SDKs for In-App Messages and push, and it can use the familiar methods and syntax that already used for push.

Single API — User can use the same APIs, segments, and other features that may use for push notifications to send your In-App Messages as well.

Prerequisite

1. Xamarin Framework

2. Huawei phone

3. Visual Studio 2019

4. OneSignal Account

App Gallery Integration process

1. Sign In and Create or Choose a project on AppGallery Connect portal.

2. Navigate to Project settings and download the configuration file.

3. Navigate to General Information, and then provide Data Storage location.

OneSignal SDK Integration process

1. Choose Huawei Android (HMS) and provide app name.

2. Choose Xamarin then click Next: Install and Test.

3. Copy your App Id.

4. Navigate to One Signal’s Dashboard > Messages > In-App.

5. Set your In-App Message here.

Installing the Huawei ML NuGet package

1. Navigate to Solution Explore > Project > Right Click > Manage NuGet Packages.

2. Search on Browser Com.OneSignal and Install the package.

Xamarin App Development

1. Open Visual Studio 2019 and Create A New Project.

2. Configure Manifest file and add following permissions and tags.

3. Create Activity class with XML UI.

MainActivity.cs

This activity performs user specific in-app messages which is sent by developer with help of OneSignal’s In-App Messages APIs.

reward_activity.xml

sent_email_activity.xml

progress_dialog.xml

Xamarin App Build Result

1. Navigate to Build > Build Solution.

2. Navigate to Solution Explore > Project > Right Click > Archive/View Archive to generate SHA-256 for build release and Click on Distribute.

3. Choose Archive > Distribute.

4. Choose Distribution Channel > Ad Hoc to sign apk.

5. Choose Demo keystore to release apk.

6. Build succeed and click Save.

7. Result.

Tips and Tricks

1. We recommend updating to the latest version of the OneSignal SDK.

2. If you are still having issues, use our SDK setLogLevel method to VERBOSE logging in your app. Reproduce the error with this logging and contact support@onesignal.com with the full log from the device.

Conclusion

In this article, we have learned how to integrate OneSignal In-App Messages in Xamarin based Android application. Developer can send messages to users for new update or user specific changes.

Thanks for reading this article. Be sure to like and comment to this article, if you found it helpful. It means a lot to me.

Reference

OneSignal In-App Messages APIs: https://documentation.onesignal.com/docs/in-app-quickstart#in-app-message-analytics

--

--