Step1:
- First Log on to the Azure Management Portal. (https://portal.azure.com/)
- After that click on +New at the bottom of the page.
- Click on App Services-> Mobile Engagement-> Create.
- One popup appears, enter the following information.
1. Application Name: Enter your application name.
2. Platform: Select platform as windows universal.
3. Application Resource Name: It is auto generated.
4. Location: Select the data Centre where this app will be hosted.
- And then click the OK button(it is in bottom of the page),it will create the application.
- Select the app and click on connection info.
- Copy the connection string,it will helps you to connect with mobile engagement to your universal app
Step2: Create a new Windows Universal App project
- In Visual studio click on new project, select the store apps then select the Universal App and then select the HubApp.
Step3: Connect your app to Mobile Engagement
- Install Mobile engagement windows universal SDK nuget package in your project.
- Click on tools, select Nuget Package Manager, in that select package manager console.
- Click on package manager console, write the following sentence Install-Package MicrosoftAzure.MobileEngagement
- The Mobile engagement windows universal SDK was installed.
- If you are targeting both Windows and Windows Phone platforms then you will need to do this for both the projects.
- Open Package.appmanifest, check the internet(client)
- Now paste the connection string in EngagementConfiguration.xml file, between the
<connectionstring>paste your connection string here</connectionstring>tags:
- Open App.xaml.cs,write the following namespace
- using Microsoft.Azure.Engagement;
- Insert the SDK in the on launched method:
- protected async override void OnLaunched(LaunchActivatedEventArgs e)
- {
- EngagementAgent.Instance.Init(e);
- Insert the following code in onActivated method:
- protected override void OnActivated(IActivatedEventArgs e)
- {
- EngagementAgent.Instance.Init(e);
- }
- Open the Mainpage.xaml.cs, write the following namespace
- using Microsoft.Azure.Engagement;
- Replace the Page class with Engagement Page.
- Add following namespace in Mainpage.xaml.
- xmlns:engagement="using:Microsoft.Azure.Engagement"
- <engagement:EngagementPage
Step4: Check your app is connected with real time monitoring or not
- This section helps you that your App connected to Mobile Engagement or not.
- In Azure Portal, click on mobile engagement and then click on engage button at the bottom, as shown below.
- You will move to the settings page of your Engagement Portal for your app, click on the monitor tab as shown below
- Go to visual studio, run your app.
- If it worked, you should now see one session in the monitor in real time!
How to Report the Events, Jobs, Errors and Crashes
Engagement API:
- By using Engagement API, we can achieve application specific events, errors and jobs and application activities in a different way.
- The Engagement API is provided by the EngagementAgent class. You can access to those methods through EngagementAgent. Instance.
Engagement concepts:
- Sessions and Activity
- Jobs
- Events
- Errors
- Crash
Sessions and Activity:
- Session means use of the application performed by a user.
- An activity is one use of a given sub-part of the application performed by one user.
Reporting Activities:
- You want to report activities, write the below code on navigated method.
- EngagementAgent.Instance.StartActivity("Example");
- Run your application after completion of the code.
Check your application (Activity) is connected with real Monitoring or not:
- Login to azure portal and click on mobile engagement and click on your created application.
- And then click on engage and then you move to settings page, click on Monitor
Jobs:
- Jobs are used to report actions having a duration
- A job is not related to a session, because task can be performed in background, without any user interaction.
- In left side click the sessions, in that sessions you can see the activity also.
Reporting Jobs:
- You want to track jobs in your Application, write the below code.
- EngagementAgent.Instance.StartJob("uploaddata",extras);
- Run your application and check the job analytics in azure portal.
Events:
- Events are used to report actions performed by a user.
There are three types of events:
- Standalone Events
- Session Events
- Job Events
Session Events:
- Session events are usually used to report the actions performed by a user during session.
- You want to track the session event, write the following code.
- EngagementAgent.Instance.SendSessionEvent("sessionevent",null);
- Above code is for without data.
- You want to track the event with data, write the below code
- Dictionary<object,object>extras=new Dictionary<object,object> ();
- extras. Add (name, data);
- EngagementAgent.Instance.SendSessionEvent ("sessionEvent", extras);
Job Events:
- Job events are usually used to report the actions performed by a user during a Job.
- You want to track the job event, write the below code.
- EngagementAgent.Instance. SendJobEvent ("eventName", "jobName", extras);
Errors:
- Errors are used to report issues detected by the application
Report Errors:
There is three types of errors:
- Standalone Errors
- Session Errors
- Job Errors
Session Errors:
- Session errors are usually used to report the errors impacting the user during his session.
- You want to report the session errors,you need to write the below code.
- EngagementAgent.Instance.SendSessionError("errorName", extra);
- Run your application and check the session errors in azure portal.
- Run your application and check the session errors in azure portal.
- You can see the Error details also by clicking the Details in Errors.
Job Errors:
- Errors can be related to a running job instead of being related to the current user session.
- You want to report the job errors, you need to write the below code.
- EngagementAgent.Instance.SendJobError(errorname,jobname,extra);
- Run your application and check the session errors in azure portal.
Crashes:
- Crashes are issued automatically by the Mobile Engagement SDK to report application failure.
Report Crashes:
- You want to report the crashes, you need to write the below code.
- EngagementAgent.Instance.SendCrash(aCatchedException);
- You can see crashes in details by clicking the details.
Alerts:
- Click on Alert,it will open window ,in that click on new alert.
- In Type dropdown list, select any one of the option as per your requirement.
- Fill the below required fields as per your requirement and click the create button.
- It will create the alert to the Notification address (email).
So whenever the given criteria reached an alert mail will go to the given email id.
How to send push notifications in mobile engagement
-
You’ll have to associate your app with a Windows Store App to obtain your
Package security identifier (SID)
and yourSecret Key
(Client Secret). You can create an app from the Windows Store Dev Center and then make sure to Associate App with Store from Visual Studio. -
Navigate to the Settings of your Mobile Engagement Portal, and click
Native Push
section on the left. -
Click the
Edit
button to enter yourPackage security identifier (SID)
and yourSecret Key
as shown below:
There are three types of push notifications in mobile engagement they are:
1. Announcements
2. Polls
3. Data Pushes
1. Announcement’s:
- In app.xaml.cs file you have to write the below code in on launched and on activated methods.
- EngagementReach.Instance.Init(e);
- In Mainpage.xaml.cs file you can add the following code in on Navigate to method.
- base.OnNavigatedTo(e);
Go to azure portal click on reach then click on announcements and then click on New Announcements
- Give name to the campaign.
- In notifications section, select the any one.
- · Any time is used to send the notifications at any time.
- · In session is used to send the notification in user activity time.
- · In activity means, it is used to send the notifications to the selected activity.
- Fill the required fields in notification section that means Title to your notification, Message and you want to send image with notification upload the image also.
- In content section, select the type of your announcement.
- If you select Notification only, it will send notifications.
- If you select Text announcement, it will send announcements.
- Defines the text to your announcements.
- Give title to your announcement and add the announcement.
- Action button means user perform some action. Give some name to that action text like OK.
- Exit button means user want to close the announcement, this button will works. Give some name to that Exit button like CANCEL.
- After fill this required fields click on create button.
- It will create the announcement, after that click on activate.
- It will send announcements to the users.
- The Announcement will be like this in the app.
- Click the announcement, It will open the app and it will be like this in the app.
- Select statistics in announcements to see how many users received that selected announcement and how many were replied to it.
- It will show the graph like this.
- It will show user performance.
2. Polls:
- In app.xaml.cs file you have to write the below code in on launched and on activated methods.
- EngagementReach.Instance.Init(e);
- In Mainpage.xaml.cs file you can add the following code in on Navigate to method.
- base.OnNavigatedTo(e);
Go to azure portal click on reach then click on Polls and then click on New Poll
- Give name to the campaign.
- In notifications section, select any one.
- Any time is used to send the notifications at any time.
- In session is used to send the notification in user activity time.
- In activity means, it is used to send the notifications to the selected activity.
- Fill the required fields in notification section that means Title to your notification, Message and you want to send image with notification upload the image also.
- Defines the text to your poll.
- Give title to your poll and add the description.
- Action button means user perform some action. Give some name to that action text like OK.
- Exit button means user want to close the announcement, this button will works. Give some name to that Exit button like CANCEL.Add question to your poll.
- After fill this required fields click on create button.
- It will create the poll, click on Activate, it will send Poll to the users.
- The poll will be like this
- Open the Poll ,it will open the app and the poll will look like the below
User can answer the poll as per their request, if they don’t want to they simply can click on cancel to dismiss the POLL
- Select the statistics in poll.
- It will show the graph like this.
- It will show user performance.