Showing posts with label Xamarin. Show all posts
Showing posts with label Xamarin. Show all posts
0
Posted on 6:20 AM by Softminer and filed under , ,

First download the sample here:
https://developer.xamarin.com/samples/monodroid/Firebase/FCMNotifications/

Then you have to create a project in Firebase
http://firebase.google.com

download google-services.json
right click on the google-service.json and set the Build Action vlaue to GoogleServicesJson



when your app is running the device get the token.

To send notification to device you need serverkey which you get from firebase server and token which you get from device in running mode

To send by postmann



you can write small c# code to post to sever by webclient:


using (var client = new WebClient())
     {
        var values = "{\"to\" : \"toekn",\"notification\" : {\"body\" : \"test\",\"title\" : \"title\",\"icon\" : \"myicon\"}}";
         client.Headers.Set("Content-Type", "application/json");
          client.Headers.Set("Authorization", "key=serverkey");
         var response = client.UploadString("https://fcm.googleapis.com/fcm/send", values);
         }


Using Microsoft Azure

using System;
using Microsoft.Azure.NotificationHubs;

namespace SendToNotificationHub
{
    class Program
    {
        public static string connectionString = "Endpoint=sb://app.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=yourkey";
        public static string NotificationHubPath = "your-hub";

        static void Main(string[] args)
        {
            SendNotificationAsync();
            Console.ReadLine();
        }


        private static async void SendNotificationAsync()
        {
            NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString
            (connectionString, NotificationHubPath);
            var alert = "{\"aps\":{\"alert\":\"Hi!\"}}";
            await hub.SendAppleNativeNotificationAsync(alert);
        }
    }
}
1
Posted on 3:32 AM by Softminer and filed under ,

After installing Android SDK you need to enable Accelerator for having Fast emulator

To publish Xamarin Project on Google play:

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/

You dont need to do all above steps mentioned in xamarin website. (e.g create a google play account and upload it via browser)

Choose release instead of Release ( Goole play doesnt allow Debugging)

RightClick on Publish and then click on Archive.

After Archiving click on Distribute there you have to define a signing identity (Adhoc) then you can click on Save As and export the project.


Then you have to zipalign the apk file:

Update 2023: No need to sign it manually using Zipalign. just use abb format and after Disturbution can be uploaded to the play directly:

go to android skd folder

C:\Users\"username"\AppData\Local\Xamarin\MonoForAndroid\AndroidSDK

and jumped into “android-sdk\build-tools\” and for ease, pasted my .APK here.

open a terminal and navigated to the build tools folder, and typed in the followng command


1
zipalign.exe -f -v 4 mono.samples.helloworld-Signed.apk helloworld.apk