. NET docking Aurora message push

What is APP message push?

Many mobile apps will push messages to users from time to time. For example, some news apps will push the news that users may be interested in, or if the APP has been updated, they will push the user whether to choose to update, etc. This is the so-called "message push".

For more information about APP message push, please refer to this article: Ten minutes to let you know about APP message Push 👉

The following are some common examples of APP message push in our daily life:

Strong marketing:

The marketing strength and marketing mode are directly displayed in a Hawking way. The purpose is to arouse users' psychology of greed for small and cheap and curiosity through preferential treatment and timeliness, as shown below:

Strong relevance:

In the era of information explosion, the brain will automatically screen valuable information and worthless information. If there are words like @ you and you in a message, the brain will automatically recognize it. The skill of using direct correlation is to skillfully use the words related to "you".

Strong hot spots: the attraction of hot spots to eyeballs is self-evident, but for hot spots, news and information have natural advantages in hot topics due to their own attributes, while other types of apps have less than satisfactory interpretation and tracking of hot spots, especially in copywriting. Don't tease users without Durex's ability, On the contrary, it seems to have no level.

Strong topic:

There is a saying in the marketing circle that you can't create communication without a sense of disobedience, and you can't create topics without being out of position. Such highly topical copywriting has its own communication attribute, which will generally hit a certain feeling in the hearts of users, such as cynicism towards society, rebellious against high house prices, literary and artistic heart of tourism, and so on.

Aurora push introduction

JPush is a tested large-scale App push platform, pushing tens of billions of messages every day. After integrating SDK, developers can push messages by calling API. At the same time, JPush provides a visual web console to send notifications and statistically analyze the push effect. JPush fully supports Android, IOS and winphone.

Why choose Aurora as the message push platform of APP?

  1. First, Aurora push supports multi platform push
  2. Support large-scale message push
  3. Aurora push docking is convenient, and different back-end languages provide corresponding SDK s
  4. It is also very friendly to support free accounts (but there is a resource bottleneck during the peak period of free accounts. If you need to be timely, you can buy advanced charging services)

Privilege comparison 👉

Fast docking Jpush Aurora push

Aurora detailed docking document 👉

  • Go to the official website of Aurora push Register developer account
  • Sign in Enter the management console, create an application, and get the Appkey (SDK and server can identify each other through Appkey);
  • In push settings, set the package name for Android, upload the certificate for iOS, enable WinPhone, and choose according to your needs;

. NET FX 4.5 project access

Is based on this project /. # # Net (. Example of net framework 4.5.1) Aurora push docking instance, mainly for the integration of Aurora docking for us SKD provided by Neter. Here, I mainly encapsulate three push methods: single device registration ID push, device registration ID batch push and broadcast push. For other push methods, you can refer to the documentation for encapsulation.

JPuhs-Sample 👉 (Packaging example source code)

1. Introduce jiang.com into the project Jpush nuget package

2. Aurora push call

namespace Jpush.Controllers
{
    /// <summary>
    ///Aurora push management
    /// </summary>
    public class JPushManageController : Controller
    {

        private readonly JPushClientUtil _jPushClientUtil;

        public JPushManageController(JPushClientUtil jPushClientUtil)
        { 
          this._jPushClientUtil=jPushClientUtil;
        }


        /// <summary>
        ///Single device registration ID push
        /// </summary>
        /// <returns></returns>
        public ActionResult SendPushByRegistrationId()
        {
            var isOk = _jPushClientUtil.SendPushByRegistrationId("Time chasers welcome you!", "2022 happy new year", "1507bfd3f715abecfa4", new Dictionary<string, object>(), true);

            return Json(new { result = isOk });
        }


        /// <summary>
        ///Batch push of device registration ID (up to 1000 at a time)
        /// </summary>
        /// <returns></returns>
        public ActionResult SendPushByRegistrationIdList()
        {
            var registrationIds = new List<string>() { "1507bfd3f715abecfa455", "1507bfd3f715abecfa433", "1507bfd3f715abecfa422" };
            var isOk = _jPushClientUtil.SendPushByRegistrationIdList("Time chasers welcome you!", "2022 happy new year", registrationIds, new Dictionary<string, object>(), true);

            return Json(new { result = isOk });
        }


        /// <summary>
        ///Broadcast push
        /// </summary>
        /// <returns></returns>
        public ActionResult BroadcastPush()
        {
            var isOk = _jPushClientUtil.BroadcastPush("Time chasers welcome you!", "2022 happy new year", new Dictionary<string, object>(), true);

            return Json(new { result = isOk });
        }

    }
}

3. Aurora push tool class (JPushClientUtil)

namespace Jpush.Common
{
    /// <summary>
    ///Aurora push tool class
    /// </summary>
    public class JPushClientUtil
    {
        private const string appKey = "youAppKey";
        private const string masterSecret = "youMasterSecret";
        private static JPushClient client = new JPushClient(appKey, masterSecret);

        /// <summary>
        ///Single device registration ID push
        /// </summary>
        ///< param name = "title" > push title (Android only exists) < / param >
        ///< param name = "noticecontent" > notification content < / param >
        ///< param name = "registrationid" > device registration ID (registration_id) < / param >
        ///< param name = "extraparam" > Expand parameters (some parameter identifiers received by the incoming App) < / param >
        ///< param name = "isapnsproduction" > note: whether iOS pushes the production environment (true yes, false no development environment) < / param >
        /// <returns></returns>
        public bool SendPushByRegistrationId(string title, string noticeContent, string registrationid, Dictionary<string, object> extrasParam = null, bool isApnsProduction = true)
        {
            //Equipment identification parameter splicing
            var pushRegistrationId = new RegistrationIdList();
            pushRegistrationId.registration_id.Add(registrationid);

            return JPushBaseSendMessage(title, noticeContent, isApnsProduction, pushRegistrationId, extrasParam);
        }

        /// <summary>
        ///Batch push of device registration ID (up to 1000 at a time)
        /// </summary>
        ///< param name = "title" > push title (Android only exists) < / param >
        ///< param name = "noticecontent" > notification content < / param >
        ///< param name = "registrationids" > registration ID(registration_id) list, pushing up to 1000 < / param >
        ///< param name = "extraparam" > Expand parameters (some parameter identifiers received by the incoming App) < / param >
        ///< param name = "isapnsproduction" > note: whether iOS pushes the production environment (true yes, false no development environment) < / param >
        /// <returns></returns>
        public bool SendPushByRegistrationIdList(string title, string noticeContent, List<string> registrationIds, Dictionary<string, object> extrasParam = null, bool isApnsProduction = true)
        {
            //Equipment identification parameter splicing
            var pushRegistrationId = new RegistrationIdList();
            pushRegistrationId.registration_id.AddRange(registrationIds);

            return JPushBaseSendMessage(title, noticeContent, isApnsProduction, pushRegistrationId, extrasParam);
        }

        /// <summary>
        ///Broadcast push
        /// </summary>
        ///< param name = "title" > push title (Android only exists) < / param >
        ///< param name = "noticecontent" > notification content < / param >
        ///< param name = "extraparam" > Expand parameters (some parameter identifiers received by the incoming App) < / param >
        ///< param name = "isapnsproduction" > note: whether iOS pushes the production environment (true yes, false no development environment) < / param >
        /// <returns></returns>
        public bool BroadcastPush(string title, string noticeContent, Dictionary<string, object> extrasParam = null, bool isApnsProduction = true)
        {
            return JPushBaseSendMessage(title, noticeContent, isApnsProduction, null, extrasParam, true);
        }

        /// <summary>
        ///Aurora message push public method
        /// </summary>
        ///< param name = "title" > push title (Android only exists) < / param >
        ///< param name = "noticecontent" > notification content < / param >
        ///< param name = "pushregistrationid" > device registration ID (registration_id) < / param >
        ///< param name = "isapnsproduction" > whether IOS pushes the production environment (true yes, false no development environment) < / param >
        ///< param name = "extraparam" > extension parameters < / param >
        ///< param name = "isradiobaroadcast" > whether to broadcast < / param >
        /// <returns></returns>
        private bool JPushBaseSendMessage(string title, string noticeContent, bool isApnsProduction, RegistrationIdList pushRegistrationId, Dictionary<string, object> extrasParam, bool isRadioBroadcast = false)
        {
            try
            {
                object audience = pushRegistrationId;

                if (isRadioBroadcast)
                {
                    audience = "all";
                }

                var pushPayload = new PushPayload()
                {
                    Platform = new List<string> { "android", "ios" },//Push platform settings
                    Audience = audience,//Push target
                    //Notification: notification content body. Is the content pushed to the client. Together with message, they must have one or both, and they can coexist.
                    Notification = new Notification
                    {
                        Alert = noticeContent,//Notice content
                        Android = new Android
                        {
                            Alert = noticeContent,//Notice content
                            Title = title,//Notice title
                            URIActivity = "com.king.sysclearning.platform.app.JPushOpenClickActivity",//This field is used to specify the activity that the developer wants to open. The value is the "android:name" attribute value of the activity node; Adapt to channel jump of Huawei, Xiaomi and vivo manufacturers
                            URIAction = "com.king.sysclearning.platform.app.JPushOpenClickActivity",//This field is used to specify the activity that the developer wants to open. The value is the "android:name" attribute value of the "activity" - "intent filter" - "action" node; Adapt oppo, fcm jump
                            Extras = extrasParam //Here, you can customize the Key/Value information in JSON format for business use.
                        },
                        IOS = new IOS
                        {
                            Alert = noticeContent,
                            Badge = "+1",//This item specifies that the badge of this push will automatically add 1
                            Extras = extrasParam //Here, you can customize the Key/Value information in JSON format for business use.
                        }
                    },
                    Options = new Options//Optional parameters
                    {
                        //Inconsistent iOS environment: API pushes messages to iOS, and APNs needs to be set_ Production specifies the push environment. false is development and true is production.
                        IsApnsProduction = isApnsProduction// Set the iOS push production environment. Do not set default to development environment.
                    }
                };

                var response = client.SendPush(pushPayload);
                //200 must be right. All exceptions do not use the 200 return code
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }
    }

    public class RegistrationIdList
    {
        /// <summary>
        ///Device registration ID
        /// </summary>
        public List<string> registration_id { get; set; } = new List<string>();
    }
}

Related link address

Added by jhuaraya on Sat, 12 Feb 2022 06:29:57 +0200