Cross platform Xamarin & Windows plugins for PCLs
We moved our plugins to individual repositories and made newer improved versions. You can check out our plugins here:
Each plugin has a README with more information on what they contain.
Cross platform Xamarin & Windows plugins for PCLs
License: MIT License
Cross platform Xamarin & Windows plugins for PCLs
We moved our plugins to individual repositories and made newer improved versions. You can check out our plugins here:
Each plugin has a README with more information on what they contain.
I have one question, a little bit of struggle regarding PCL method:
public class CrossPushNotificationListener : IPushNotificationListener
{
public void OnMessage (JObject values, DeviceType deviceType)
{
Debug.WriteLine ("Message Arrived");
}
.......
I didn’t quite understood how to set (customize) “Notification” Title, Icon, Subject, Message text OnMessage event ?
Let’s say that receiving object values (JObject) contains strings/values for Notification Title, Subject, Message , so what would be the right aprouch in PCL project to applay these values before Notification is pop uped on user screen (both Android & iOs) ?
Thank's in advance for answer or suggestion.
Is compass included at all? Or it could be separate as well.
Is it possible to disable/enable the sounds for remote push notifications?
For avoid
01-29 14:20:35.280: E/AndroidRuntime(31479): java.lang.Error: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.InvalidOperationException: You MUST call Xamarin.Forms.Init(); prior to using it.
01-29 14:20:35.280: E/AndroidRuntime(31479): at Xamarin.Forms.Device.get_PlatformServices () [0x00007] in <filename unknown>:0
01-29 14:20:35.280: E/AndroidRuntime(31479): at Xamarin.Forms.Device.GetAssemblies () [0x00000] in <filename unknown>:0
01-29 14:20:35.280: E/AndroidRuntime(31479): at Xamarin.Forms.DependencyService.Initialize () [0x00000] in <filename unknown>:0
01-29 14:20:35.280: E/AndroidRuntime(31479): at Xamarin.Forms.DependencyService.Get[T] (DependencyFetchTarget fetchTarget) [0x00007] in <filename unknown>:0
And dor call native fuction
I first want to personally thank you for creating a Plugin for Xamarin for our holiday contest. To get your exclusive Xamarin Swag Bag out to you I just need a bit more information from you. If you can email: [email protected] with the following information we will get the bag out to you.
Name
Street Address
City, State, Zip Code
Country
Phone Number
The URL to this repo
Thank you again and I hope to see even more plugins from you in the future. Always feel free to reach out if you need anything.
I want to register my client to specifics topics, but i didn't find any support about this. Are you going to implement this? Is there any alternative to keep developing with this current version?
another small question, is it possible to translate the incoming message, depending on the device language?
Hi,
First of all, thank you for sharing this plugin. I've been following the instructions and got this error. Do you have any idea of what I'm missing?
Added the NuGet Package to the shared project, iOS and Android.
Added initialization line in MainActivity and AppDelegate
Minimum y Target Android version are set to Automatic
Xamarin.Forms version - is 1.3.5.6333 pre-1
Xamarin.Android.Support.v4 - updated to latest version
Xamarin.Android.Support.v7.AppCompat - updated to latest version
Xamarin.Android.Support.v7.MediaRouter - updated to latest version
I'm at a loss as to how this could ever work on Android. The PushNotificationRegistrationIntentService
class defines a SubscribeTopics
method, but nothing ever calls it! See here. Therefore, the client is never subscribed to any topic. :/
All this does is create spurious exceptions. Why not just pass the message through and let the application deal with it?
Initialization via a static Initialize
method which creates the type for you is not friendly for DI. It makes everything ass-backwards. I have to let CrossPushNotification create my listener, extract it via CrossPushNotification.PushNotificationListener
, then inject that into my container.
It would be useful to have overloads that take an already instantiated instance of T
:
var composition = new CompositionRoot();
var listener = composition.ResolvePushNotificationListener();
CrossPushNotification.Initialize(listener);
Failed to load AOT module '/Users/builder/data/lanes/2689/962a0506/source/maccore/builds/install/target7/lib/mono/aot-cache/arm/PushNotification.Plugin.dll.so' in aot-only mode.
Hi, I followed all the instructions for using the plugin. I'm able to receive the notifications while the App is running but when I close the App, the notifications are not received.
I have started properly the service: StartPushService as described in the documentation, in fact when the App is running I see that the service is also running (settings->Apps administration->Running...) but when the App is closed the service is removed also from the list of running Apps.
Is is possible to receive Push notifications on Android when the App is closed using this Plugin? I checked that in order to receive, the Service needs to derive from WakefulBroadcastReceiver in order to receive then the App is closed. Check: http://forums.xamarin.com/discussion/29804/push-notifications-on-closed-app-with-forms
Cheers
Ariel
Hi, I have implemented your library in my Android project. When my device receives a notification it show in the notification center but doesn't give a popup. Any idea how to fix this?
I am successfully using the plugin on Android, but with iOS it fails during initilization.
iOS 8.4:
Should initialize before use on FinishedLaunching method of AppDelegate class. Example: CrossPushNotification.Initialize()
iOS 7.1:
UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
Last point of entry before the exceptions occur: CrossPushNotification.Current.Register()
This is my AppDelegate FinishedLaunching:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
CrossPushNotification.Initialize<CrossPushNotificationListener>();
InitXLabsServices();
ImageCircleRenderer.Init();
LoadApplication(new KinsmenApp());
return base.FinishedLaunching(app, options);
}
Of course I did set up the Provisioning Profile and Push Notification Permission at the Developer Center.
How can I get more information about where it actually crashes inside the plugin?
Edit:
I took a look at the plugin's source code and after using the following three lines directly it registered successfully, but this way I am not using the Plugin:
UIUserNotificationType userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
UIUserNotificationSettings settings = UIUserNotificationSettings.GetSettingsForTypes(userNotificationTypes, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
Could it be possible that the preprocessor directives aren't getting handled properly and therefore the wrong code gets executed?
One thing that I want to do right now is to respond to the user selecting a notification.
In particular I want to have payload information stored with the notification, and have a method, say, on the IPushNotificationListener that gets triggered when the user selects a notification.
As a specific example, I'd be generating push notification for changes in particular DB models. When the user selects a notification, I want to show the page specific for the model object that actually changed.
It seems that the current notifications, on Android at least, have the following set:
.SetAutoCancel(true) // dismiss the notification from the notification area when the user clicks on it
Any idea how to handle this?
I do get a token but it won't receive push messages, any ideas?
I need to implement push notification,
I'm using Azure Messaging client with GcmClient, but im having some problems, like the app crash when receive notification while app is open.
So, i need to find another solution, is your still working ?
I tried adding the PushNotification plugin to an Xamarin.Android project that targets API level 21 and when I try to call CrossPushNotification.Current.Register()
I get this exception:
[MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.CallStaticObjectMethod'.]
PushNotification.Plugin.PushNotificationsReceiver.OnReceive(Android.Content.Context,Android.Content.Intent) in c:\xamarin-plugins\PushNotification\PushNotification\PushNotification.Plugin.Android\PushNotificationsReceiver.cs:34
Android.Content.BroadcastReceiver.n_OnReceive_Landroid_content_Context_Landroid_content_Intent_(intptr,intptr,intptr,intptr) in /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Content.BroadcastReceiver.cs:334
at (wrapper dynamic-method) object.cf39052a-7755-4cfc-bb54-e69d5073bce6 (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x00027>
I'm not entirely sure what might be causing this issue, but I can't seem to find a way around it.
When using an android:targetSdkVersion >= 21 the small icon of a notification is limited in design:
'For 5.0 Lollipop "Notification icons must be entirely white".' When a notification icon is to colorful if will be defaulted to a white square with a grey circle as background.
For now it is possible to create a white small icon that will be used in the status bar, as well as the small icon, but it is not possible to set the background color.
In the builder add this to set the background color: builder.setColor(color), which will only affect the small icon background in the notification center.
A workaround to keep a colored notification icon is to set the android:targetSdkVersion to <21
Is there a way to not create a notification if the user is currently in/using the app?
I know in iOS this seems to be the default behavior.
tl;dr The Xamarin.Forms' DependancyService
prevents Android apps from receiving push notifications when not running or backgrounded.
I recommend updating the tutorial on the Push Notification Plugin's GitHub page to help prevent confusion from other developers in the future: Adding Push Notification Post to your Xamarin Forms Application. I followed this tutorial to implement the Push Notification Plugin, and it lead me to this road block: my Android app could not receive push notifications when it was not running or backgrounded.
After following this step-by-step tutorial to setup the Push Notification Plugin on Xamarin.Forms, the iOS push notifications work flawlessly and the Android devices receive push notifications when the app is running or backgrounded. But on Android, if I force-close the app so that it is no longer running (e.g. press the Recent Apps button, and swipe away my app), and then send a push notification, the device shows this error message: “Unfortunately, [App Name] has stopped” (screen shot below).
The error below was appearing because I did not call the CrossPushNotification.Initialize<CrossPushNotificationListener>(Keys_Constants.GOOGLE_APIs_ID);
method inside [Application] OnCreate()
as is recommended on the Push Notification Plugin's GitHub page.
But, the reason why I didn’t/couldn’t include this method in [Application] OnCreate()
was because CrossPushNotificationListener
requires the Xamarin.Forms’ DependencyService
, which is impossible in [Application] OnCreate()
because the DependencyService
hasn’t been initialized yet; global::Xamarin.Forms.Forms.Init(this, bundle);
is called in Android's MainActivity
which hasn’t been yet instantiated when the code is executing the [Application]
class.
The remedy was to break apart my cross-platform implementation of the CrossPushNotificationListener
into a platform-specific NotificationListener
that now live in the platform-specific PCL (code below).
I recommend updating the tutorial on the GitHub page to implement this plugin for Xamarin.Forms. The tutorial has the user create a CrossPushNotificationListener
class that uses Xamarin.Forms’ DependencyService
. This tutorial works flawlessly to receive push notifications on iOS, but on Android, it will only allow the device to receive push notifications while the app is running or backgrounded.
using System;
using Android.OS;
using Android.App;
using Android.Content;
using Android.Runtime;
using Plugin.CurrentActivity;
using PushNotification.Plugin;
using Xamarin;
namespace MondayPundayApp.Droid
{
//You can specify additional application information in this attribute
[Application]
public class Punday : Application, Application.IActivityLifecycleCallbacks
{
public static Context AppContext;
public Punday(IntPtr handle, JniHandleOwnership transer)
: base(handle, transer)
{
}
public override void OnCreate()
{
base.OnCreate();
RegisterActivityLifecycleCallbacks(this);
AppContext = this.ApplicationContext;
CrossPushNotification.Initialize<AndroidPushNotificationListener>(Keys_Constants.GOOGLE_APIs_ID);
StartPushService();
}
public override void OnTerminate()
{
base.OnTerminate();
UnregisterActivityLifecycleCallbacks(this);
}
void IActivityLifecycleCallbacks.OnActivityCreated(Activity activity, Bundle savedInstanceState)
{
CrossCurrentActivity.Current.Activity = activity;
}
public void OnActivityDestroyed(Activity activity)
{
}
public void OnActivityPaused(Activity activity)
{
}
public void OnActivityResumed(Activity activity)
{
CrossCurrentActivity.Current.Activity = activity;
}
public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
{
}
public void OnActivityStarted(Activity activity)
{
CrossCurrentActivity.Current.Activity = activity;
}
public void OnActivityStopped(Activity activity)
{
}
public static void StartPushService()
{
AppContext.StartService(new Intent(AppContext, typeof(PushNotificationService)));
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
PendingIntent pintent = PendingIntent.GetService(AppContext, 0, new Intent(AppContext, typeof(PushNotificationService)), 0);
AlarmManager alarm = (AlarmManager)AppContext.GetSystemService(Context.AlarmService);
alarm.Cancel(pintent);
}
}
public static void StopPushService()
{
AppContext.StopService(new Intent(AppContext, typeof(PushNotificationService)));
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
PendingIntent pintent = PendingIntent.GetService(AppContext, 0, new Intent(AppContext, typeof(PushNotificationService)), 0);
AlarmManager alarm = (AlarmManager)AppContext.GetSystemService(Context.AlarmService);
alarm.Cancel(pintent);
}
}
}
}
using PushNotification.Plugin;
using PushNotification.Plugin.Abstractions;
using Newtonsoft.Json.Linq;
using MondayPundayApp.Droid;
namespace MondayPundayApp.Droid
{
public class AndroidPushNotificationListener : IPushNotificationListener
{
AzureNotificationHubService_Android _azureNotificationHubService;
public AndroidPushNotificationListener()
{
_azureNotificationHubService = new AzureNotificationHubService_Android();
}
public async void OnRegistered(string Token, DeviceType deviceType)
{
await _azureNotificationHubService.RegisterNativeAsync(Token);
}
public async void OnUnregistered(DeviceType deviceType)
{
await _azureNotificationHubService.UnregisterNativeAsync();
}
public void OnError(string message, DeviceType deviceType)
{
}
public void OnMessage(JObject values, DeviceType deviceType)
{
}
public bool ShouldShowNotification()
{
return true;
}
}
}
using System;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.MobileServices;
using Xamarin;
namespace MondayPundayApp.Droid
{
public class AzureNotificationHubService_Android
{
private MobileServiceClient _mobileServiceClient;
private Push _push;
public string CurrentDeviceId { get; private set; }
public AzureNotificationHubService_Android()
{
try
{
_mobileServiceClient = new MobileServiceClient(Keys_Constants.AzureMobileService_URL, Keys_Constants.AzureMobileService_KEY);
_push = _mobileServiceClient.GetPush();
}
catch (Exception e)
{
Insights.Report(e);
}
}
public async Task UnregisterNativeAsync()
{
try
{
await _push.UnregisterNativeAsync();
}
catch (Exception e)
{
Insights.Report(e);
}
}
public async Task RegisterNativeAsync(string deviceId)
{
try
{
CurrentDeviceId = deviceId;
await _push.RegisterNativeAsync(deviceId);
}
catch (Exception e)
{
Insights.Report(e);
}
}
}
}
Now it require Xamarin.GooglePlayServices, the lates version is very big
It may be better to just use requierd packages:
http://redth.codes/Xamarin-Google-Play-Services-Improvements/
Rendy, is any way how to set an Activity which is called after the click on the notification?
Or open the main Activity of the app?
Or do you plan to add it to the code? (for ex. like here: https://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/android/local_notifications_in_android_walkthrough/ )
The thread 'Unknown' (0x13) has exited with code 0 (0x0). 01-29 16:37:45.194 D/Mono (10062): Assembly Ref addref Xamarin.GooglePlayServices.Gcm[0x556a97b0e0] -> Xamarin.Android.Support.v4[0x556a96d670]: 5
01-29 16:37:45.243 W/art (10062): JNI RegisterNativeMethods: attempt to register 0 native methods for md563bb5d7cd114ceda82ec85fb57ce3637.PushNotificationsReceiver Thread started: #25
01-29 16:37:45.506 D/Mono (10062): Assembly Ref addref PushNotification.Plugin[0x556a965290] -> Newtonsoft.Json[0x556a959b50]: 8
01-29 16:38:06.432 I/art (10062): Thread[5,tid=10071,WaitingInMainSignalCatcherLoop,Thread*=0x556a8979a0,peer=0x32c070a0,"Signal Catcher"]: reacting to signal 3
01-29 16:38:07.080 I/art (10062): Wrote stack traces to '/data/anr/traces.txt'
Stable reproduce in debug mode
"Xam.Plugin.PushNotification" version="1.1.5"
Hi,
I'm using Pushsharp to send GCM notifications and when I send to a particular registration Id the DeviceSubscriptionExpired callback is being fired.
This plugin doesn't seem to cater for this scenario as once there's a Token stored it continues to use that without checking if it's still valid.
Can you advise when I should be calling the unregister method?
Hi,
I'm having troubles to receive notifications when the app is not started, been trying to find a solution for a while w/o success...
Here is the log I got from Android Device Monitor when I send a notification while my app is not started:
06-09 16:35:45.213: E/AndroidRuntime(7385): FATAL EXCEPTION: IntentService[null]
06-09 16:35:45.213: E/AndroidRuntime(7385): Process: com.vetup.imrvot, PID: 7385
06-09 16:35:45.213: E/AndroidRuntime(7385): md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: PushNotification.Plugin.Abstractions.PushNotificationNotInitializedException: CrossPushNotification Plugin is not initialized. Should initialize before use with CrossPushNotification Initialize method. Example: CrossPushNotification.Initialize()
06-09 16:35:45.213: E/AndroidRuntime(7385): at PushNotification.Plugin.PushNotificationImplementation.OnHandleIntent (Android.Content.Intent) <0x001d4>
06-09 16:35:45.213: E/AndroidRuntime(7385): at Android.App.IntentService.n_OnHandleIntent_Landroid_content_Intent_ (intptr,intptr,intptr) <0x0005b>
06-09 16:35:45.213: E/AndroidRuntime(7385): at (wrapper dynamic-method) object.b1a05100-dc64-4f9b-a5c5-8647af307690 (intptr,intptr,intptr) <0x00043>
06-09 16:35:45.213: E/AndroidRuntime(7385): at md563bb5d7cd114ceda82ec85fb57ce3637.PushNotificationImplementation.n_onHandleIntent(Native Method)
06-09 16:35:45.213: E/AndroidRuntime(7385): at md563bb5d7cd114ceda82ec85fb57ce3637.PushNotificationImplementation.onHandleIntent(PushNotificationImplementation.java:28)
06-09 16:35:45.213: E/AndroidRuntime(7385): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
06-09 16:35:45.213: E/AndroidRuntime(7385): at android.os.Handler.dispatchMessage(Handler.java:102)
06-09 16:35:45.213: E/AndroidRuntime(7385): at android.os.Looper.loop(Looper.java:136)
06-09 16:35:45.213: E/AndroidRuntime(7385): at android.os.HandlerThread.run(HandlerThread.java:61)
Everything is fine when the app is started (got focus or in the background).
I followed your instructions in PushNotificationStarted.txt to start the service.
And my app is a Xamarin Form app, here is a code extraction for the initialization (onCreate):
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
public static Context AppContext;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
AppContext = this.ApplicationContext;
global::Xamarin.Forms.Forms.Init (this, bundle);
//Sender Id pour com.vetup.imrvot => 845213152730
CrossPushNotification.Initialize<CrossPushNotificationListener>("845213152730");
StartPushService();
LoadApplication (new App ());
}
Thank you very much in advance for any input
Philippe
Is there a way we can get a simple example project that uses the Push Notification plugin? The docs are a bit confusing and i'm not sure how i'm supposed to implement all the parts even after reading the txt files etc.
After upgrade I get the error when push notification arrives:
12-22 23:34:31.285 E/mono ( 1453): Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: Integer. Path '', line 1, position 1.
12-22 23:34:31.285 E/mono ( 1453): at (wrapper dynamic-method) System.Object:38ab4821-8395-4444-b869-68cb019a5379 (intptr,intptr,intptr,intptr)
12-22 23:34:31.285 E/mono ( 1453): at (wrapper native-to-managed) System.Object:38ab4821-8395-4444-b869-68cb019a5379 (intptr,intptr,intptr,intptr)
12-22 23:34:31.285 E/mono-rt ( 1453): [ERROR] FATAL UNHANDLED EXCEPTION: Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: Integer. Path '', line 1, position 1.
12-22 23:34:31.285 E/mono-rt ( 1453): at (wrapper dynamic-method) System.Object:38ab4821-8395-4444-b869-68cb019a5379 (intptr,intptr,intptr,intptr)
12-22 23:34:31.285 E/mono-rt ( 1453): at (wrapper native-to-managed) System.Object:38ab4821-8395-4444-b869-68cb019a5379 (intptr,intptr,intptr,intptr)
I've defined my OnMessage as follows:
public void OnMessage(JObject values, DeviceType deviceType)
{
Debug.WriteLine("Message Arrived");
try
{
}
catch (Exception ex)
{
}
}
In 1.0.10 it was:
public void OnMessage(IDictionary<string, object> Parameters, DeviceType deviceType)
{
Debug.WriteLine("Message Arrived");
try
{
LastScreen = Parameters["screen"].ToString();
}
catch (Exception ex)
{
}
}
What do I do wrong?
Thanks in advance for any help.
I'm having the following problem in an XForms project for Android: Push notification error - CrossPushNotification - Register - Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
In this project that is working for iOS I use PushSharp on my server.
Hi,
Thanks your code. During app state is open, or home button background mode, it is work. But App state is closed or kill not working push notification. Why?
Please help me?
Thanks.
Is it possible to get a heads-up notification without modifying the code and set the priority to high?
I am using your library in one App for Android and IOS.
Working properly all the notifications I get them.
But I have 2 questions
-the plugin is only compatible with bees 21 then with Android for example 4.4 does not work? I've actually tried and didn't see any problems.
-I made a service like from template that receives notifications in the background and it works, but when the user clicks on the notification message even if the App is active, reloads.
Because at startup My App is slow because it has several requests via REST, is not working properly at the user level.
How do I fix it?
I haven't figured out why yet, but every message I send is received twice by PushNotificationGcmListener
.
Before thank you for your NuGet.
I have a problem when I recieve a push notification from my server .
here is the stack trace :
I'm on android device 5.0.2
Java.Lang.Error: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
at Android.Gms.Gcm.GcmListenerService.n_OnMessageReceived_Ljava_lang_String_Landroid_os_Bundle_ (intptr,intptr,intptr,intptr) <IL 0x0001c, 0x0013b>
at (wrapper dynamic-method) object.f47bf664-6d00-4721-9ca8-6ebada36b60e (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x0004b>
at --- End of managed exception stack trace ---
at java.lang.Error: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
at at Android.Gms.Gcm.GcmListenerService.n_OnMessageReceived_Ljava_lang_String_Landroid_os_Bundle_ (intptr,intptr,intptr,intptr) <IL 0x0001c, 0x0013b>
at at (wrapper dynamic-method) object.f47bf664-6d00-4721-9ca8-6ebada36b60e (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x0004b>
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at at java.lang.Thread.run(Thread.java:818)
at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.TypeLoadException: Could not load type 'Android.OS.BaseBundle' from assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
at at Android.Gms.Gcm.GcmListenerService.n_OnMessageReceived_Ljava_lang_String_Landroid_os_Bundle_ (intptr,intptr,intptr,intptr) <IL 0x0001c, 0x0013b>
at at (wrapper dynamic-method) object.f47bf664-6d00-4721-9ca8-6ebada36b60e (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x0004b>
at at md563bb5d7cd114ceda82ec85fb57ce3637.PushNotificationGcmListener.n_onMessageReceived(Native Method)
at at md563bb5d7cd114ceda82ec85fb57ce3637.PushNotificationGcmListener.onMessageReceived(PushNotificationGcmListener.java:28)
at at com.google.android.gms.gcm.GcmListenerService.zzs(Unknown Source)
at at com.google.android.gms.gcm.GcmListenerService.zzk(Unknown Source)
at at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
at at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at ... 2 more
Thank you for your help
hi
The setup link does not work
*Step by step instructions: Adding Push Notification Post to your Xamarin Forms Application
*
Hi,
as the title says, is it possible to prevent the notification to pop up, depending on the content?
The onMessage is fired before displaying anything, so my idea was to check the content and then decide whether or not to display. Is it possible to interrupt at any point?
The OnRegistered method is triggered one time and only after deleting the App and installing it again, if I have the App already installed (and being using it) the OnRegistered is not triggered anymore.
Is any way to force it? or tell me if I'm doing something wrong. I have the "Register()" call in the OnStart of the App (Form App).
protected override void OnStart () {
// Handle when your app starts
CrossPushNotification.Current.Register();
}
Hi,
public async void OnMessage (Newtonsoft.Json.Linq.JObject values, PushNotification.Plugin.Abstractions.DeviceType deviceType)
{
if (deviceType == DeviceType.iOS) {
Debug.WriteLine (values.SelectToken("aps"));
}
Gives me the following output:
{
alert = "This is a test alert.";
badge = 0;
sound = default;
}
I want to parse alert
but it seems like I can't since the "
are missing around it, right?
How can I retrieve the string This is a test alert.
?
Any tipps / ideas?
BR
Hello,
I think the ShouldShowNotification should be reconsidered on how it currently works as it also differs from the platforms and feels weird.
For example if you override it to return true Android will try to show a local notification (code reformatting required there btw) but iOS does nothing as there is no default implementation, and neither the ones should they ever be implemented.
The ShouldShowNotification feels more like an implementation for one to check to see if the user desired to see notifications or in your own configuration is allowed.
I think thus the ShouldShowNotification should be called before OnMessage and has the bool supplied so the implementer knows if it should show or is allowed to show a notification, but you can also determine that for yourself in the handling of the OnMessage.
Though I think if disabled on the platform one will not be shown one anyway, and thus could be considered removed?
please help
I got 1 error message in CrossPushNotificationListener's IPushNotificationListener.OnError method
Error :
CrossPushNotification - Register - Java.IO.IOException: Exception of type 'Java.IO.IOException' was thrown.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0
at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0
at Android.Gms.Gcm.GoogleCloudMessaging.Register (System.String[] senderIds) [0x00000] in :0
at PushNotification.Plugin.PushNotificationImplementation+<>c__DisplayClass7.b__6 () [0x00000] in c:\xamarin-plugins\PushNotification\PushNotification\PushNotification.Plugin.Android\PushNotificationImplementation.cs:230
at System.Threading.Tasks.TaskActionInvoker+FuncInvoke1[System.String].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in <filename unknown>:0 at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename unknown>:0 at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename unknown>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 at System.Runtime.CompilerServices.TaskAwaiter
1[System.String].GetResult () [0x00000] in :0
at PushNotification.Plugin.PushNotificationImplementation+d__9.MoveNext () [0x00058] in c:\xamarin-plugins\PushNotification\PushNotification\PushNotification.Plugin.Android\PushNotificationImplementation.cs:228
--- End of managed exception stack trace ---
java.io.IOException: SERVICE_NOT_AVAILABLE
at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
at dalvik.system.NativeStart.run(Native Method)
Using latest everything getting an error loading project:
Error XA0009: Error while loading assembly: /Users/ray/Projects/MyApp/packages/Xam.Plugin.LocalNotifications.1.0.0.0/lib/portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10/LocalNotifications.Plugin.Abstractions.dll (XA0009)
Hi,
The nuget package requires nuget version 2.81 (2.8.1 ?) and can't be used on Xamarin Studio / osX :
The 'Xam.Plugin.DeviceMotion 1.1.1' package requires NuGet client version '2.81' or above, but the current NuGet version is '2.8.7.0'.
Regards
Is there a reason why the iOS implementation doesn't call 'ShouldShowNotification' and doesn't even show the notification? I only get the 'OnMessage' to fire but it doesn't do anything else. It works great on Android by showing the Notification automatically.
Hi there,
Each notification the app receives replaces the previous notification. I'd like them to stack up if possible. Is this supported at the moment? Or the near future?
The latest Nuget dll and it's targeting the SDK 21 but my project use the SDK 16. It crashes when receiving a notification. I had to rebuild the plugin with SDK 16 to make it work. Is it possible to have other dll targeting older SDK?
Hi guys (cc @rdelrosario)
Thanks for creating this amazing plugin..
I understand that windows phone supports is still on pipeline. but I like to ask some questions at early stage so we will understand whats coming up for Windows Phone.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.