-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example project for Push Notifications #7
Comments
Hi There is instructions and step by step here: http://lemoncode.net/2015/04/17/adding-push-notifications-to-your-xamarin-forms-application-part-1/ Let me know if helps. |
Hi there, The link is broken. Cannot get to the instructions. I did manage to get it working with the code on the main page, but how do I handle opening the notification? Notifications are received by my app and tapping the notification open my app, but on the first page. How can I tell it to open a specific page (I am using it for both iOS and Android in a Xamarin forms project)? |
Hi Rendy, First of all I am really thankful that you have developed the plugin for Xamarin and AWS and helping developers across the globe. I am new to mobile development and trying to develop a mobile app for andriod platform using xamrin. I do have requirement of sending notfications to indivisual devices through Amazon SNS services. |
I would also like to set an example for Android. |
Try the link of Step by step instructions on the README documentation just
|
My bad the link in the readme work just fine !! you're a boss ! thanks again !! Hello, thanks for all your work but the link is still broken ! |
I think this is the updated link from above. Though, I'm still confused on how to implement in Android to receive the device token and when a message is received. Looking at part two from the link, it still doesn't seem to show that. |
Does anyone have a working example? I'm not succeeding in implementing this. Thank you. |
If you could be more specific we could help you. |
No special requirements, but I have to be missing something. I have implemented the public class CrossPushNotificationListener : IPushNotificationListener
{
void IPushNotificationListener.OnError(string message, DeviceType deviceType)
{
Application.Current.MainPage.DisplayAlert("error", message, "ok");
}
void IPushNotificationListener.OnMessage(JObject values, DeviceType deviceType)
{
Application.Current.MainPage.DisplayAlert("message", values.ToString(), "ok");
}
void IPushNotificationListener.OnRegistered(string token, DeviceType deviceType)
{
Application.Current.MainPage.DisplayAlert("token", token, "ok");
}
void IPushNotificationListener.OnUnregistered(DeviceType deviceType)
{
Application.Current.MainPage.DisplayAlert("unregistered", "", "ok");
}
bool IPushNotificationListener.ShouldShowNotification()
{
Application.Current.MainPage.DisplayAlert("should show notification", "", "ok");
return true;
}
} In iOS’s AppDelegate, I then initialize the CrossPushNotification plugin. public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init ();
CrossPushNotification.Initialize<CrossPushNotificationListener>();
LoadApplication(new Origination.App ());
return base.FinishedLaunching(app, options);
} I have also extended the AppDelegate with the appropriate overrides as shown in the public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
if (CrossPushNotification.Current is IPushNotificationHandler)
{
((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error);
}
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
if (CrossPushNotification.Current is IPushNotificationHandler)
{
((IPushNotificationHandler)CrossPushNotification.Current).OnRegisteredSuccess(deviceToken);
}
}
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
if (CrossPushNotification.Current is IPushNotificationHandler)
{
((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);
}
}
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
if (CrossPushNotification.Current is IPushNotificationHandler)
{
((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);
}
} Afterwards, in my shared code, after the user registered/logged in the App and enter it's home screen, I call:
I know this method is being executed, as I get an alert requesting permissions. But none of the methods from the There must be something I'm not seeing here.. |
Did you install it on your real device or simulator? |
I'm testing this on a real device. My issue is that, the In fact, none of the method's from the |
Ok, I see. You're right, at least the Register callbacks of AppDelegate should be triggered. |
Same problem as nmdias, it does request permission for push notifications and calls DidRegisterUserNotificationSettings but never calls RegisteredForRemoteNotifications in order to get the device's token. For Android I've updated the payload fields that comes from Firebase on the plugin's source and now it shows the notification body on Android. But not for IOS. My CrossPushNotificationListener is on the PCL, only working for Android so far. |
Now it calls RegisteredForRemoteNotifications but when sending push it says the token is invalid using Pusher. So the token is invalid for now. It may be IOS 10 issue with this plugin. |
@gtmorais can you try adding a group to your app's entitlements? Give that a go. I honestly don't remember if that was it, as I ended up with a custom dependency service. Here's what I did, based on the plugin's source code: |
My project do not work when i register CrossPushNotification in the OnStart method. I no have a error message, but don't run. When i debug it, then get in the Service to consume, don't work. Any help is welcome. |
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.
The text was updated successfully, but these errors were encountered: