Coder Social home page Coder Social logo

azurepushnotificationplugin's Introduction

Azure Push Notification Plugin for Xamarin iOS and Android

Build Status

Simple cross platform plugin for handling azure notification hub push notifications.

Setup

Platform Support

Platform Version
Xamarin.iOS iOS 8+
Xamarin.Android API 15+

API Usage

Call CrossAzurePushNotification.Current from any project to gain access to APIs.

Features

  • Receive push notifications
  • Tag registration
  • Support for push notification category actions
  • Customize push notifications
  • Localization

Documentation

Here you will find detailed documentation on setting up and using the Azure Push Notification Plugin for Xamarin

Contributors

azurepushnotificationplugin's People

Contributors

matei-tm avatar mclillill avatar moret84 avatar plsgard avatar rdelrosario avatar zainniazi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azurepushnotificationplugin's Issues

Notifications when app closed

Guys sorry but couldn't find a place for questions. Does this plugin support notifications when the app is closed?
Thanks

Please update to support iOS 13

I used your plugin in my iOS app and everything worked fine so far. Unfortunately, with the version of iOS 13 notifications are no longer working.
I see that the source file has already changed but the Nuget package does not contain the corrections.
Could you please update the plugin? Thanks

Random Registration Issue

Hi,

For the production release, I encounter a random issue. Some devices at first launch it got registered but after a while, it will sort of de-register. These devices will not be able to receive any push notifications.

After I disable the "AutoRegistration", and On Demand RegisterForPushNotification, it works 100%.
`#if DEBUG
AzurePushNotificationManager.Initialize(this, Constants.ListenConnectionString, Constants.NotificationHubName, true, false);
#else
AzurePushNotificationManager.Initialize(this, Constants.ListenConnectionString, Constants.NotificationHubName, false, true,false);
CrossAzurePushNotification.Current.RegisterForPushNotifications();

#endif`

Please help to investigate if this is a real defect.

Thanks

Default FirebaseApp is not initialized exception

I've followed the Getting Started tutorial and once I run my app, I get this exception on the line where this is:
AzurePushNotificationManager.Initialize(this, AzureConstants.ListenConnectionString, AzureConstants.NotificationHubName, true);

The exception says this:
Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.company.xxx. Make sure to call FirebaseApp.initializeApp(Context) first.'

I've tried calling the FirebaseApp.initializeApp(this) first, it didn't help.
I've also tried switching from debug to release configuration, also didn't help.

I'm using these nugets:
Xamarin.Forms 4.4.0.991537
Plugin.AzurePushNotifications 2.0.23

My android app is targeting API 29 (Android Q).

ResetToken= True creates many new registrations for the same device

In the docs it's been recommended that as Debug ResetToken should be set to false.
However this is creating many new registrations in our NotificationHub that are for the same simulator or debug device.

I really don't want to have to remove defunct registrations constantly, so am forced to either place logic that will search based on some other means for a registration first, or find some other way to manage it.

Android notification heads-up issue

I implementing the push notification for android with firebase and testing in android 9 mobile.
Everything works fine except the heads-up not showing as I already set for priority high in the payload.

Payload example in Azure notification hubs:-
{"data":{"title":"Test", "body":"abc 123", "priority":"high"}}


Android 8 and above use channel to set important high for the heads-up. Possible to override the channel important level in onReceive event?

OnNotificationOpened isn't being called on Android

I have the following code in my Application OnCreate method.

#if DEBUG
    AzurePushNotificationManager.Initialize(this, Resources.GetString(connectionString,hubName, true);
#else
    AzurePushNotificationManager.Initialize(this, Resources.GetString(connectionString,hubName, false);
#endif

 CrossAzurePushNotification.Current.OnNotificationReceived += Current_OnNotificationReceived;  
 CrossAzurePushNotification.Current.OnNotificationOpened += Current_OnNotificationOpened; 
 CrossAzurePushNotification.Current.RegisterAsync(new string[] { "dev" });
private void Current_OnNotificationReceived(object source, AzurePushNotificationDataEventArgs e)
{
   //This gets hit
}

 private void Current_OnNotificationOpened(object source, AzurePushNotificationResponseEventArgs e)
{
   //This does not get hit
}

When I send a Firebase Push Notification, my phone will display the notification properly in the tray. When I tap on the notification, my app will open, but the OnNotificationOpened event is not fired.

My notification looks like this.

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
      "title":"My Title",
      "body":"My Body"
    }
  }
}

Java.Lang.NoClassDefFoundError

Getting the following error when running the android build -
Java.Lang.NoClassDefFoundError: 'Failed resolution of: Lcom/google/android/gms/common/internal/zzbp;'

And this is from the logs -
11-08 11:09:06.309 E/AndroidRuntime(16071): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbp" on path: DexPathList[[zip file "/data/app/uk.gov.cardiff.CardiffGov.Android-Me5H2YwmgUAAxym26dJW2w==/base.apk"],nativeLibraryDirectories=[/data/app/uk.gov.cardiff.CardiffGov.Android-Me5H2YwmgUAAxym26dJW2w==/lib/arm64, /data/app/uk.gov.cardiff.CardiffGov.Android-Me5H2YwmgUAAxym26dJW2w==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]

Not Support All the Architecture in IOS

Hi,
I not able to release the app with following build like ARMv7+ARMv7s+ARM64 .
can you please help to solve the issue.

I am getting the below error.

MT5209: Error: ignoring file , file was built for armv7 which is not the architecture being linked (armv7s): /obj/iPhone/Release/mtouch-cache/armv7/System.Core.dll.o Native linking

MT5209: Error: file is universal (4 slices) but does not contain a(n) armv7s slice: /obj/iPhone/Release/mtouch-cache/WindowsAzureMessaging.framework/WindowsAzureMessaging file '/obj/iPhone/Release/mtouch-cache/WindowsAzureMessaging.framework/WindowsAzureMessaging' for architecture armv7s Native linking
Please help me to resolve the issue

Thanks,
Tamilmani

Java.Util.MissingFormatArgumentException when using parameters in android localization string

I have followed all documentation to the letter and implemented the the plugin on android succesfully. Now I want to localize my messages and I followed the instructions to add localization without parameters. This works fine and message and title gets translated. Now I followed the documentation to add parameters.
This is my default values.xml:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
<string name="notification_title_string">Hello %1$s</string>
<string name="notification_message_string">This is a message for %1$s</string>
</resources>

Now I send a test message like the example:

{
    "data": {
          "title_loc_key" : "notification_title_string",
          "body_loc_key" : "notification_message_string",
          "title_loc_args" : ["Dominican Republic"],
          "body_loc_args" : ["Rendy"]
     },
     "priority": "high"
}

The breakpoint in

            CrossAzurePushNotification.Current.OnNotificationReceived += (s, p) =>
            {


            };

gets hit but after that I get a unhandeled: "Java.Util.MissingFormatArgumentException : Format specifier: 1$s" and the app terminates.
I am using X.F. version 3.0.0.530893 with the v27.0.2 android support libs and version 1.1.0 of the Plugin.AzurePushNotification on a Android 6 phone.

If helpfull I can create a simple sample application to demonstrate the issue?

Push Send from Backed not working

Hallo to all,
I'm testing from Azure - portal and it working.
But if i send from backend - not working.
Should i yet template register?
I use NotificationHubClient

OnNotificationOpened doesn't fire on Android

When I click a notification I expect this block to run but it doesn't.

			CrossAzurePushNotification.Current.OnNotificationOpened += (s, p) =>
			{
				Console.WriteLine("Notification opened");
				Console.WriteLine(s);
				Console.WriteLine(p);
			};

What might I be missing? Is there anything I need to add to my AndroidManifest.xml?

		<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
		<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true"
			 android:permission="com.google.android.c2dm.permission.SEND">
			<intent-filter>
				<action android:name="com.google.firebase.MESSAGING_EVENT"/>
				<action android:name="com.google.android.c2dm.intent.RECEIVE" />
				<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
				<category android:name="${applicationId}" />
			</intent-filter>
		</receiver>

Xamarin Forms Android does not receive notification when app is killed.

Android works well when in foreground or background. Does not receive notification when the app is in the killed state. I have compiled the app in release mode and removed all references to system.diagnostics.debug within my code.

I have the following permissions in Manifest.
<uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="co.my.packagename.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="co.my.packagename.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.VIBRATE" />

and the following receiver:
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

Notifications don't work on Android

I've got everything working on iOS but I struggled to get it working on Android. I tried everything and in the end I decided to test your sample application. Notifications are received (validated with breakpoint) but notifications are never shown. Exactly the issue I had with my own app. Every time I receive a notification I find these lines in the log:

[Notification] Use of stream types is deprecated for operations other than volume control
[Notification] See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case

Did I forget something? Or is it related to Android Oreo?

IOS i am getting below issue can you please check

at UIKit.UIApplicationDelegate.RegisteredForRemoteNotifications
(UIKit.UIApplication application, Foundation.NSData deviceToken)
<0x101175040 + 0x00034> in <e7de71939f4649d9bdfb2e2411afa951#02bfba1ad8fca52f5a23207648d25473>:0
at POPAPPMobile.iOS.AppDelegate.RegisteredForRemoteNotifications
(UIKit.UIApplication application, Foundation.NSData deviceToken)
<0x10051d1e0 + 0x0002f> in <b946aec22b134e4bbe47279680015bec#02bfba1ad8fca52f5a23207648d25473>:0

Xamarin.Android

I have created a new project and I cannot include this plugin. It requires packages that are not supported by the latest released or pre-released versions of Xamarin.Forms.
How do I resolve this?

Appreciate your efforts. Greg

Severity Code Description Project File Line Suppression State
Error NU1107 Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the project to resolve this issue.
TestCrossGeeks2.Android -> TestCrossGeeks2 -> Plugin.AzurePushNotification 1.1.0 -> Xamarin.Firebase.Messaging 60.1142.0 -> Xamarin.GooglePlayServices.Basement 60.1142.0 -> Xamarin.Android.Support.Compat (>= 26.0.2)
TestCrossGeeks2.Android -> Xamarin.Forms 2.5.1.340284-pre2 -> Xamarin.Android.Support.Design 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2).

isRegisteredForRemoteNotifications

Is there any cross platform way to detect if the user has already registered for push notifications? I know Apple has isRegisteredForRemoteNotifications

This would be handy on App load to check to see if they've registered somewhere else in the App, if so call register again so a new token will always update.

Notifications not being displayed if app is in the foreground on iOS

I have a xamarin forms ios app. When the app is in the foreground, the notification is not displayed, otherwise it is display. However, when the app is in the background and the notification is received tapping the "See More" opens the app and then opens the URL in a browser. I'd like to not open the app and just send the user to the URL. I've tried default as the action type, but that just closes the notification.

FinishedLaunching

`AzurePushNotificationManager.Initialize(
Global.PushNotificationsHubEndpoint,
Global.PushNotificationsHubName,
options,
new NotificationUserCategory[]
{new NotificationUserCategory("link",new List
{ new NotificationUserAction("close","Dismiss",NotificationActionType.Default),
new NotificationUserAction("open","See More",NotificationActionType.Foreground)})}, true);

CrossAzurePushNotification.Current.OnNotificationOpened += (s, p) =>
{
if (!string.IsNullOrEmpty(p.Identifier))
{
if(p.Identifier.ToLower() =="open")
{
foreach (var data in p.Data)
{
if (data.Key == "aps.url" && data.Key.ToString().Length > 0)
{
UIApplication.SharedApplication.OpenUrl(new Uri(data.Value.ToString()));
}
}
}

            }

        };

...

public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action completionHandler)
{

        AzurePushNotificationManager.DidReceiveMessage(userInfo);
    }

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
try
{
AzurePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);

        }
        catch (Exception)
        {

            //Global.GALogException(ex, "RegisteredForRemoteNotifications");
        }
    }

`

System.InvalidOperationException: Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.

Severity Code Description Project File Line Suppression State
Error The "GenerateJavaStubs" task failed unexpectedly.
System.InvalidOperationException: Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.
at Xamarin.Android.Tasks.ManifestDocument.CreateApplicationElement(XElement manifest, String applicationClass, List1 subclasses, List1 selectedWhitelistAssemblies)
at Xamarin.Android.Tasks.ManifestDocument.Merge(List1 subclasses, List1 selectedWhitelistAssemblies, String applicationClass, Boolean embed, String bundledWearApplicationName, IEnumerable`1 mergedManifestDocuments)
at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() TESTAPP.Android

Didn't receive Ios Notification

I used Azure plugin worked fine in android but in ios when i use test send in azure Notification Hub

image

Success but nothing appears in phone

any help ?

Unregistering device from notification hub

I've been noticing an issue with multiple device registration on Azure notifications hub from using this plugin. I'm not completely sure if my understanding is accurate of what is going on, but it seems that once a device gets registered with Azure hubs, it never gets unregistered from there on out. This creates issues with test devices getting registered hundreds of times during development as well as individuals phones getting registered on production when uninstalling and reinstalling for any reason. Microsofts documentation, shared in the link, shows an example of how to register a phone and shows that unregistering is the first step before trying to register. This way any previous registration is wiped clean. I looked into the repo code and didn't see any code around this.

https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management#example-code-to-register-with-a-notification-hub-from-a-device-using-a-registration

I was able to find the unregister methods in the projects source code but neither of them are accessible or used anywhere else in the project. At least from my github search there were no references past the declarations of the methods. I'm not sure if I'm missing something here in how to prevent duplicate registrations, but I'm currently unable to find a way using this plugin. Any clarity on how that is supposed to be handled, or if a PR is needed to implement it is appreciated. This is an issue that I've found others talking about online to mixed success. Seems like a pretty big documentation/clarification issues on Microsofts end to not make this use case more clear given the number of devices registered to certain tiers of their service is limited making this issue potentially eat up limited resources. Below is another link to a discussion of this issue I found on the Azure github

Azure/azure-notificationhubs-android#5

Any help or clarification is greatly appreciated since it's pretty hard to find reliable info out there about handling this use case.

Notification Icon problems when android app is stopped

Hi. We have recently started using your plugin on our mobile app.

We are setting the notification icon in MainActivity.cs with the following:

        AzurePushNotificationManager.NotificationContentTitleKey = "Some Title";
        **AzurePushNotificationManager.IconResource = Resource.Drawable.notifications;**
        AzurePushNotificationManager.ProcessIntent(this, Intent);

The notifications are being received correctly. The icon displays fine when the notification is received when the app is in the foreground or background. The problem we are experiencing is as follows:

When the app is killed / stopped and a notification is received, our samsung devices, will display a white box rather than the icon.
When the app is killed / stopped and a notification is received, our Huawei device displays the app icon rather than the notification icon (which is an improvement to the samsung, but still confusing).

In androidmanifest we have:

<application android:label="Test App" android:icon="@drawable/icon" android:largeHeap="true" android:allowBackup="false" android:theme="@style/Light" android:usesCleartextTraffic="true">

At the top of MainActivity.cs we also have:

[Activity(Label = nameof(OurApp), Icon = "@drawable/icon", Theme = "@style/Light", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize, ScreenOrientation = ScreenOrientation.Portrait)]

which also refers to the app icon. I'm not sure which of these 2 places, the app icon is being picked up from on the Huawei.

Do you have any ideas why we have the inconsistencies and how to can get the Samsung devices to display an icon please?

Thank you for a great plugin.

Sarah

There is no way to set the large icon on Android

It turns out that Android uses different notification icons for the status bar and for the drawer notification panel. NotificationCompat.Builder has setSmallIcon method and setLargeIcon method to handle each case, but AzurePushNotificationPlugin only allows to set IconResource property which is mapped to setSmallIcon as seen here. It would be great too have a way to set the large icon too.

Thanks

Support for Firebase 60.1142.1

I need to upgrade several Xamarin.Firebase packages from 60.1142.0 to 60.1142.1 and this plugin is prohibiting me from upgrading. Any timeline to release a version that is compatible with .1?

Registration failed (invalid tag)

Hi,

I have implemented your plugin, it seems to go well in the debugger.
However, registration at Azure gives the following error:

Fail to perform registration operation.
"User-Agent" = "NOTIFICATIONHUBS/2013-04(api-origin=IosSdk; os=iOS; os_version=11.3.1;)";
Error Response:400An invalid tag(s) '' was supplied. Valid tag characters are alphanumeric, _, @, -, ., : and #.TrackingId:39662438-750c-4e45-95fe-caacb3674

I am sure I send in one tag and that is not an empty string.

Also, when I send this I get the same error:
CrossAzurePushNotification.Current.RegisterAsync(new string[] { "test1", "test2" });

Anything wrong on my side?

Thanks for your answer.
Frank

Initialize option where no direct connection to NotificationHub is required

We are following Microsofts recommended path for device Installation using a back end API to do registrations etc. The backend API is responsible for connecting to the hub and the App does not at all.

Is there a way to Initialize the plugin without the connection strings for the hub, so it can receive/handle notifications only?

If not please can this be added, or documentation explaining how to achieve it.
If initialization is not required for receiving/handling notifications using the plugin, please can this be explained as an option in the docs.

Update nuspec

Severity Code Description Project File Line Suppression State
Warning NU1608 Detected package version outside of dependency constraint: Plugin.AzurePushNotification 1.1.0 requires Xamarin.Firebase.Messaging (= 60.1142.0) but version Xamarin.Firebase.Messaging 60.1142.1 was resolved.

Thank you for your work!

AzurePushNotificationManager.Initialize ResetToken=false

Thanks for your great work, I tried AzurePushNotificationSample and I noticed that in MainApplication.cs AzurePushNotificationManager.Initialize if I set ResetToken = false the registration doesn't happen, if ResetToken = true the registration works.
In version 1 everything was working

showing no popup/notification when channel_id of message is populated

I've setup several channels in the app. When I send a message without a channel id, the message is received and I also get a phone popup.
If I add a channel id, I still receive the message, but no phone popup.

if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
//Change for your default notification channel id here
AzurePushNotificationManager.DefaultNotificationChannelId = NotificationConstants.NOTIFICATION_CHANNEL_ID;

            //Change for your default notification channel name here
            AzurePushNotificationManager.DefaultNotificationChannelName = "General";

            NotificationManager notificationManager = (NotificationManager)GetSystemService(Android.Content.Context.NotificationService);

            notificationManager.CreateNotificationChannel(new NotificationChannel(
                    NotificationConstants.NOTIFICATION_MAILERS_CHANNEL_ID,
                    "Mailers",
                    NotificationImportance.High));

            notificationManager.CreateNotificationChannel(new NotificationChannel(
                NotificationConstants.NOTIFICATION_REMINDER_CHANNEL_ID,
                "Reminders",
                NotificationImportance.High));
        }

...

{
"data": {
"title": "Closing Date due today",
"body": "closing on property 100 main street",
"priority": "high",
"icon": null,
"large_icon": null,
"sound": null,
"id": null,
"channel_id": "reminder_channel",
"silent": "false",
"click_action": null,
"custom_data": {
"CustomerParcelId": "ba9109f5-44ad-4714-9c1d-c1cf32d12cae",
"UserId": "de589fe4-5585-46f7-8b7a-33d960c8f295",
"NotificationId": "ab55a64e-9182-4cea-ad66-7719cb500141"
}
}
}

Clear all unread notifications

If my app receives multiple push notifications, I would like them all to be cleared when the user opens the application. Both if the user clicks on a notification, and if a user just opens the application from menu. Or if user just unlocks the phone and the application was current application behind lock screen.

But I could not find an option to clear all notifications for my app, or have I missed something?

Not sending Subscription to Azure Notification Hub on iOS

I have the plugin setup on AppDeleate like this:

            AzurePushNotificationManager.Initialize(AzureConstants.ListenConnectionString, AzureConstants.NotificationHubName, options);
            AzurePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Badge | UNNotificationPresentationOptions.Sound;

I've configured my Azure Notification Hub. It prompts me to accept notifications which I do, however nothing is ever sent to Azure. My notification hub never receives a subscription.

I've subscribed to OnNotificationError but not seeing anything there.


            CrossAzurePushNotification.Current.OnNotificationError  += async (s, p) =>
            {
                await AppHelper.CurrentPage.Instance.DisplayAlert("OnNotificationError", p.Message, "Ok");
            };

Unable to register android device on azure push notification hub

I have followed the sample application for android to register the device but to no avail. After login I call
await CrossAzurePushNotification.Current.RegisterAsync(tags) in the loginviewmodel. The code executes fine and not error. But when I go to the Azure notification hub, active device registered is zero. The same code works for ios but not sure why it does not work for android

Token not get picked up on app restart

when receiving the notification for the 1st time it works fine but when the app restarts the token is empty and the app crashes see below for screenshots;

Screenshot 2020-11-16 at 23 21 10

my implementation below;

on appdelgete

        UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, true); // <--- copy this instruction

        LoadApplication(new App(new iOSInitializer()));

        AzurePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Sound;
        AzurePushNotificationManager.Initialize(NotificationContstants.ListenConnectionString, NotificationContstants.NotificationHubName, launchOptions, true);
        return base.FinishedLaunching(uiApplication, launchOptions);
    }

    public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
    {
        AzurePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
    }

    public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
    {
        AzurePushNotificationManager.RemoteNotificationRegistrationFailed(error);

    }

    // To receive notifications in foregroung on iOS 9 and below.
    // To receive notifications in background in any iOS version
    public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
    {
        AzurePushNotificationManager.DidReceiveMessage(userInfo);
    }

on the app.xaml.cs file my implementation; onstart();

        // Handle when your app starts
        CrossAzurePushNotification.Current.OnTokenRefresh += (s, p) =>
        {
            Debug.WriteLine($"PushNotification TOOKEN REC: {p.Token}");
        };

        Debug.WriteLine($"PushNotification TOOKEN: {CrossAzurePushNotification.Current.Token}");

        CrossAzurePushNotification.Current.OnNotificationOpened += (s, p) =>
        {
            //System.Diagnostics.Debug.WriteLine(p.Identifier);

            Debug.WriteLine("Opened");
            foreach (var data in p.Data)
            {
                Debug.WriteLine($"{data.Key} : {data.Value}");
            }

            if (p.Data["aps.type"].ToString() == "Ecards")
            {
                Settings.WasLaunchedFromPush = true;
                Preferences.Set("IsFromHomePage", true);
                var instanceID = p.Data["aps.parameters"];
                Debug.WriteLine(instanceID);

                var navigationParams = new NavigationParameters();
                navigationParams.Add("questionInstanceID", instanceID);
                NavigationService.NavigateAsync("ECardQuestionPage", navigationParams, true, false);

            }
            else
            {
                Settings.WasLaunchedFromPush = true;
            }
        };

        CrossAzurePushNotification.Current.OnNotificationDeleted += (s, p) =>
        {
            Debug.WriteLine("Dismissed");
        };

Azure Notification Hub doesn't work

Hey guys,

I'm doing some tests with Android, but when I send a test message through Azure Notification Hub, I receive the following message on the portal: "Message was successfully sent, but there were no matching targets." and the notification does not reach the device / emulator.
When I do the test through Firebase the notification works normally.
Even running the examples, the problem is the same.

Please, did anyone have the same problem and manage to solve?

Not filtering via tags - Android

I register my app when the user signs on with tag for the userId.

await CrossAzurePushNotification.Current.RegisterAsync(new string[] { UserContext.UserIdentifier });

I setup a few channels

notificationManager.CreateNotificationChannel(new NotificationChannel(
NotificationConstants.NOTIFICATION_MAILERS_CHANNEL_ID,
"Mailers",
NotificationImportance.High));
...

I send with the tag of the userId and have the channel id in the jsonString, among others
var results = await hub.SendFcmNativeNotificationAsync(jsonString, tag);

The problem I have is that it sends the message to everybody, not just the one user. How do I filter so just the one user gets the message

Registration Security

If the notification hub connection string is in the app, wouldn't that allow an attacker to register for other user's notifications? For instance if the system uses integer primary keys, and I am user ID 20, I could create a registration for user ID 21 by essentially forging the registration request and intercept users ID 21's notifications.

Is the work around to abstract way the integers with guids?

Thanks for your guidance on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.