Open notification in Xamarin.Forms - xamarin

How can I open a notification in Xamarin. Forms?, I have implemented that receives and shows the notifications even if it is inside the application but I lack the action of the notification, not that to do...

I think you want to fire an action when user clicks your "OK" button on your message which includes notification message. I suggest you to use a custom dialog project like this:
Acr.UserDialogs
When you import that library, u can call a message and give an action method to its interface: (code may not compile, i wrote it randomly)
UserDialogs.Instance.Alert(new AlertConfig
{
Message = "Your notification message",
OkText = "OK",
OnAction = ()=>{/*youraction*/}
});
So when user taps on "OK" your action code will run. Do not forget to use "Device.BeginInvokeOnMainThread" method if you make UI changes:)

Related

Outlook Add-in that just directs to a website

I want to program a simple Outlook add-in that opens a browser and take the user to a specific site.
I've had a look at using Yeoman, but this add-in opens a task pane where I'm just looking to take that single actions.
Is there a simple way to do this?
EDIT:
I managed to get this done, but I not have the following issue: I have a single button (via Yeoman's generator) that when clicked executes the following:
function action(event) {
const message = {
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
message: "Window opened.",
icon: "Icon.80x80",
persistent: true,
};
// Show a notification message
window.open("https://myurl.com");
Office.context.mailbox.item.notificationMessages.replaceAsync("action", message);
// Be sure to indicate when the add-in command function is complete
event.completed();
}
I get the following error in Outlook itself:
We deployed the app using the MS 365 admin center, but I'm not sure if there is something additional that I need to do in this case to run the webserver?
There is an Office.js API that will open a browser window:
Office.ui.openBrowserWindow( -- URL string here -- );
This will cause the computers default browser to open to the specified URL. You could have a button in the task pane whose handlers calls this method. Alternatively, you could have a custom button on the ribbon that calls a FunctionFile that calls this method.
If you want to display any web site to the user as a result of the button click or some action on the pane, try doing window.open('https://yoursite.com'). This should work if the domain is whitelisted in your manifest. For example:
function redirectFunction() {
window.open("https://othersite.com")
//window.location.href = "https://othersite.com";
}

(3D touch) How to open a specific page in the application when the user kill the application?

I'm using 3D Touch and Quick Actions to navigate to "Search" page in my application.
I handle event click Shortcut button at method PerformActionForShortcutItem() of AppDelegate.cs::
public override void PerformActionForShortcutItem(UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler)
{
bool handledShortCutItem = HandleShortCutItem(shortcutItem);
completionHandler(handledShortCutItem);
}
At method HandleShortCutItem(), I send a MessagingCenter to MainPageViewModel.cs:
MessagingCenter.Send(new SearchContactEventMessage(), nameof(SearchContactEventMessage));
At method Initialize() of MainPageViewModel.cs, I subscribe the above MessagingCenter:
MessagingCenter.Subscribe<SearchContactEventMessage>(this, nameof(SearchContactEventMessage), message =>
{
// TODO Open page Search in my app
.....
}
It's work (can open "search" page) when my app is running foreground or background.
If my app don't open or user kill it, "Search" page couldn't be showed.
Can give me an idea when user "kill" app and they use "Quick Actions", my application can show a certain page in the application.
Cause:
Once you click and send the MessagingCenter when user "kill" app, in you MainPageViewModel.cs, it has not subscribe the MessagingCenter because your app is terminated. So, it won't receive the MessagingCenter and Open page Search in your app.
Solution:
I would suggest you open search page directly in the handledShortCutItem method.

Xamarin Forms Map pin renderer open page

I am prety new with Renderers on Xamarin. I am following this tutorial (https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/map/customized-pin/) to make a custom pin. The problem it's the following:
I need to do a custom pin, the custom pin only has 2 default labels and 1 Button. That button needs open a page from PCL project. How can I do that click button go to PCL page?
You can send a message from your custom MapRenderer whenever a pin is clicked using the Xamarin MessagingCenter like so:
Xamarin.Forms.MessagingCenter.Send(YourObject, "PinClicked");
And then subscribe to that message somewhere in your PCL, like so:
MessagingCenter.Subscribe<string> (this, "PinClicked", (YourObject) => {
// show the correct page whenever the "PinClicked" message
// is sent, using the details in YourObject
});
});
Don't forget to unsubscribe when you no longer wish to receive messages.

Mac OS X 10.8 NSUserNotification alert notification don't get dismissed

In our app we are displaying Notifications in alert style.
Displaying notification is working fine and we also get callback when user interacts with the notification either by clicking on notification or by clicking on Action button.
But the Alert Notification Pop up stay on the screen instead of going away even after user has dismissed it by clicking on the content of the notification.It goes away only after clicking close button.Pop up stay on the screen where as notification get cleared from notification center.
Is there is any solution to dismiss pop up when user click the content of alert notification.
You'll need to handle this manually. Implement the delegate method -userNotificationCenter:didActivateNotification: like this:
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
if (notification.activationType == NSUserNotificationActivationTypeContentsClicked) {
[center removeDeliveredNotification:notification];
}
}

How to get to the Messaging app to text someone?

I'm making an app and I want to be able to go from my app to the messaging app straight to the "Create new" page. Is there a way I can navigate to that page straight from my app?
As Andrew M mentioned, the SmsComposeTask is the correct control to use. Here is some sample code for you:
SmsComposeTask smsTask = new SmsComposeTask();
smsTask.To = "0123456789"; // the number you would like to send the sms to
smsTask.Body = "Some prefilled text..."; // if you would like to fill some text
smsTask.Show();
When Show() is called, the app will navigate to the Messaging application and display an SMS filled in with the defined parameters.
Simply use the above code in an event handler (i.e., the event for when a button is clicked), and the user will be navigated accordingly.
Use the SMSComposeTask:
http://www.nickharris.net/2010/09/how-to-sms-using-the-smscomposetask-for-windows-phone-7/

Resources