Intermediate: OneSignal Email APIs Integration in Xamarin (Android)

Manoj Kumar
4 min readJun 18, 2021

--

Overview

In this article, I will create a demo app along with the integration of OneSignal Email APIs which is based on Cross platform Technology Xamarin. It provides an easy-to-use email building interface that allow user to construct fantastic templates for all your emails.

OneSignal Service Introduction

OneSignal supports email as a messaging channel to provide you with more ways to reach users.

Single SDK- User won’t need to manage separate SDKs for email and push, and it will be able to use the same 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 emails 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 > New Email.

5. Enter Email Details.

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 email send operation with help of OneSignal’s Email APIs.

email_activity.xml

sent_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. OneSignal does not act as its own email service provider, you will need to sign up for one.

2. Email and push subscribers will have separate OneSignal Player IDs. This is to manage the case where a user opts-out of one you can still send them messages to the other.

3. To configure email, you will need to modify your domain’s DNS records. Different email service providers have different requirements for which records need modifying, which likely include MX, CNAME, and TXT types.

Conclusion

In this article, we have learned how to integrate OneSignal Push Notification in Xamarin based Android application. Developer can send OneSignal’s Push Message to users for new updates or any other information.

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.

References

OneSignal Email API https://documentation.onesignal.com/docs/email-overview

--

--

Manoj Kumar
Manoj Kumar

No responses yet