I am working with Xamarin UWP along with Azure notification hub to send Push notifications. I have the toast notifications showing up just fine, but when I click on the toast I need to be able to view the message. I can get a message to show up from the OnLaunched method when the notification is touched, with something like this:
string text = string.Format("Launched with parameter: " + args.ToString());
MessageDialog dialog = new MessageDialog(text);
await dialog.ShowAsync();
I can't figure out how to retrieve the message that was sent from the toast notification.
I ended up setting my text in the launch parameter to receive it in OnActivated
Related
I'm using firebase-admin on nodejs to send push notifications to users:
https://firebase.google.com/docs/admin/setup
I'm using firebase_messaging on flutter:
https://pub.dev/packages/firebase_messaging
I'm trying to send a push notification with the highest priority on both android and ios.
firebase.messaging(firebaseApp).send({
token,
notification,
android: { priority: 'high' },
apns: { headers: { 'apns-priority': '10' }, payload: { aps: { sound: 'default' } } },
data
}
On my development devices it works like a charm both when the app is in the background and when it's terminated.
I'm receiving push notifications that visibly pop and make a sound 100% of the time, on both android and ios.
The issue is on other devices -
If the app is in the background, I can sometimes see an actual push notification visibly pop, and make a sound as it should. Sometimes not.
If the app is terminated, a push notification is received - but it doesn't visibly pop nor make a sound, I can only see it if I scroll down the menu from the top of the screen, it's listed as a received push notification.
Sometimes the notification is not receieved at all.
I tried to change the priority of notifications from my app to high on the actual device as well, but it didn't change anything.
My users keep complaining that they're not receiving push notifications - I'm guessing they either actually don't receieve them or simply don't see them since they're recieved silently as I described above.
I literally have no idea what's going on and why it doesn't work as it should on devices other than my own development devices.
Any ideas?
There are two tags that need to be intact when we are sending push from firebase api
priority
android_channel_id
If android 7.0 or 8.0 above device do not receive the android_channel_id than it will not show notification and so always set default notification channel in the android manifest.
we can check available tags in json request we are setting via node.
from here
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id"/>
like this and make sure you create the notification channel at mobile end.
String CHANNEL_ID = "your_channel id";
String CHANNEL_DESCRIPTION = "Your description to show in settings";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_DESCRIPTION, NotificationManager.IMPORTANCE_HIGH);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
If you see the flutter app logs it will show you some error like default channel not set in manifest or no channel found in notification.
make sure you put logs in your question to resolve this or contact me to resolve the issue.
Also make sure you read
Optionally handle background messages section from here fcm flutter lib
there they mentioned adding fcm in android folder.
I toast notification by Azure Notification hub to UWP Application from ASP.NET website but when I click in notification it opens app and suspend in splash screen then it close immediately , how I fix this problem ??
I use this tutorial :
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-windows-store-dotnet-get-started-wns-push-notification
when I click in notification it opens app and suspend in splash screen then it close immediately
Frequently, OnLaunched is invoked when UWP application is launched and this method is initial created. But if you want to launch the app by toast which ActivationKind is ToastNotification, you may need to handle the activated event by overriding the OnActivated event handle. For example:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.ToastNotification)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
var rootFrame = CreateRootFrame();
rootFrame.Navigate(typeof(MainPage));
Window.Current.Activate();
}
}
More details please reference Handle URI activation and the Notification official sample.
I was experimenting with a kik bot using Node.js, while I was trying to get a static keyboard to appear when user sends a 'help' message, it only sent the two replies and the static keyboard does not pop up. According to me it should work.
This is the function that sends the help messages:
/**
*
* #param {Message} message
*
*
*/
function help(message) {
message.reply('Hello!');
message.reply('Choose from the options to get an idea of what I can do! ;)');
message.addResponseKeyboard(['Rate me', 'Set reminder', 'Info']);
}
This is the bot configuration:
let bot = new Bot({
username: 'purppbot',
apiKey: 'dba843db-18bb-45fe-b6d6-3a678f420be2',
baseUrl: 'https://purppbot1-xbeastmode.c9users.io/',
staticKeyboard: new Bot.ResponseKeyboard(['Help', 'Info'])
});
I honestly don't know about Node.js; but as far as I see, I think you are expecting Static Keyboard to do what a Suggested Response Keyboard would do.
Regarding Static Keyboard, according to the API Reference of Kik docs, The static keyboard allows you to define a keyboard object that will be displayed when a user starts to mention your bot in a conversation, whilst regarding Suggested Response Keyboard, A suggested response keyboard presents a set of predefined options for the user.
It means the static keyboard is shown when a user starts to mention your bot in a conversation; and it disappears once a message is sent to the bot. And when the bot sends back a message to the user, it will contain its message(s) and Suggested Response Keyboard sent by the bot along with the message. In case no Suggested Response Keyboard is sent by the bot along with the message(s), the static keyboard is not shown until the user again starts to mention the bot's username.
So, in your case, you might want to send the those responses through Suggestive Responses Keyboard, which your bot would need to send along with the text message, every time a user sends the 'help' message.
I hope this helps.
I wants to send an image stored in the drawable folder to some other app using ACTION_SEND ,my code is given below:
if(view.getId()==R.id.sendimage) {
Uri imageUri=Uri.parse("android.resource://"+getPackageName()+"/drawable"+R.drawable.screen);
intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM,imageUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
chooser=intent.createChooser(intent,"Send Image Via");
startActivity(chooser);
}
But when i try to send using button in my app to Gmail a toast message "Can't attach empty file " appears and similar message also appear in other apps too while sending and some app even crashes.
So could you please help me in figuring out the mistake??
I have some problems with my Push Notifications. I can sent them well to my registered Devices. All works fine.
My Questions is: After clicking the VIEW button, the App is launching. At the moment without any content.
How can i add content here? This content should depend on the Push Notification i sent out.
For example: My Push Notification is about NEWS XYZ - then after clicking VIEW i should get more informations about NEWS XYZ
So i think i must get the news from my website. Perhabs with the ID they are posted on my side.
But how to implement this in the App?
I mean with every NEW Push Message, the must be shown the NEW News.
Also it should be possible to read all previous received NEWS in the App in a list, when getting back from NEWS Number 1.
You understand, what i mean?
I dont have any real idea...Would be nice if you can show me code regarding to an example.
Thanks.
This method invokes once you tap on the view button on the push notification,
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if (application.applicationState == UIApplicationStateInactive) {
// Application came from the background
// Here you can request for the content
// This has the value of your payload
UILocalNotification *localNotif = (UILocalNotification *) [userInfo objectForKey:#"aps"];
}
else if (application.applicationState == UIApplicationStateActive) {
// Application is in the foreground
}
}