adenearnshaw / appshortcutsplugin Goto Github PK
View Code? Open in Web Editor NEWAppShortcuts plugin for Xamarin and Windows
License: MIT License
AppShortcuts plugin for Xamarin and Windows
License: MIT License
At least on Android, every time a shortcut is pressed, with the application in memory, the constructor is initialized again with a new navigation stack. Then the shortcut page opens, but if I go back, it goes back to the previous navigation stack.
Is there a way to remove the old navigation stack? Or add the shortcut page to the existing stack?
Thanks and regards.
Each Shortcut has a ShortcutId property, which is set internally as it needs to be unique every new Shortcut instance.
As highlighted in #19 if a user uninstalls and re-installs an app that's only storing a history of its pins locally, there's no way to tell if a business object has already been pinned.
Add a "Tag" property to the Shortcut whose value can be assigned by the user for their own comparison purposes.
it opens the DetailPage inside the DetailPage
even if i select another shortcut(like the About page in the GIF)
it show that page with a back button and when i press that back button result is the same :(
i think i'm doing something wrong or missing but i don't know what.
using Plugin.AppShortcuts;
using Plugin.AppShortcuts.Icons;
using System;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using XamNote.Views;
namespace XamNote
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class App : Application
{
public const string AppShortcutUriBase = "mhr://XamNote/";
public const string ShortcutOption1 = "Note";
public const string ShortcutOption2 = "About";
[Obsolete]
public App()
{
AddShortcuts();
InitializeComponent();
MainPage = new MainPage();
}
public async void AddShortcuts()
{
if (CrossAppShortcuts.IsSupported)
{
var shortCurts = await CrossAppShortcuts.Current.GetShortcuts();
if (shortCurts.FirstOrDefault(prop => prop.Label == "Note") == null)
{
var shortcut = new Shortcut()
{
Label = "Note",
Description = "Go to Home",
Icon = new HomeIcon(),
Uri = $"{AppShortcutUriBase}{ShortcutOption1}"
};
await CrossAppShortcuts.Current.AddShortcut(shortcut);
}
if (shortCurts.FirstOrDefault(prop => prop.Label == "About") == null)
{
var shortcut = new Shortcut()
{
Label = "About",
Description = "Go to About",
Icon = new ContactIcon(),
Uri = $"{AppShortcutUriBase}{ShortcutOption2}"
};
await CrossAppShortcuts.Current.AddShortcut(shortcut);
}
}
}
protected override void OnAppLinkRequestReceived(Uri uri)
{
var option = uri.ToString().Replace(AppShortcutUriBase, "");
if (!string.IsNullOrEmpty(option))
{
MainPage = new NavigationPage(new MainPage());
switch (option)
{
case ShortcutOption1:
MainPage.Navigation.PushAsync(new ItemsPage());
break;
case ShortcutOption2:
MainPage.Navigation.PushAsync(new AboutPage());
break;
}
}
else
base.OnAppLinkRequestReceived(uri);
}
}
}
// OK it seems the emulator is not able to react to 3D Touch that's certainly why it does not work.
// You can certainly close this issue (or let some message to warn users this does not work on emulator
Version Number of Plugin: 1.0.0.3
Device Tested On:
Simulator Tested On: iPhone 8 iOS 12.0
Version of VS: latest, up to date
Version of Xamarin: 3.3.0.912540
Versions of other things you are using:
Launch demo app, show monkey details, Pin, all is right, no error message, no error in the code (tracking executed code in debug mode, no failure)
See something like a shortcut on the iPhone screen
Nothing. Monkey is pinned but not shortcut is displayed
nothing to see
Additional notes
Perhaps there is something with iOS 12, I can't test on prior versions.
Long press on Icons does not show anything (just moving icons on the screen), iOS does not react as Android or UWP that's ok. But Where are the shortcuts to be displayed ?
As there is no screen capture along with your sample code it is hard to tell what to expect visually, what should be seen on screen and how to access shortcuts with iOS...
Of course, thanks for this plugin !
And thanks in advance for your answer
Regards
Olivier
Menu items not working in UWP!
Version Number of Plugin: 1.0.0.3
Device Tested On: PC
Version of VS: 16.5.4
Version of Xamarin: 4.6
Version Number of Plugin: 1.0.0.3
Device Tested On: Windows UWP
Simulator Tested On: No
Version of VS: 2019
Version of Xamarin: 4.5.0.495
Versions of other things you are using:
Run the Sample App from VS 2019 and Pin some of the Monkeys
Uninstall the App
Run the Sample App from VS 2019 again and Pin some more Monkeys
Pins from the old installation are gone and only the new Pins are pinned
In the App, these pins can be unpinned
The Pins from the old installation seams to be stored somewhere and are replied again to the App Icon on right click of the mouse
While Running the new Installation, the saved pins should be possible to unpin. But the App itself does not recognize that there are already some of them
I added/changed this code
private const int MaxPinsThreshold = 0;
public async Task PinMonkey(Monkey monkey)
{
if (await MaxNumberOfPinsReached())
{
**CrossAppShortcuts.Current.RemoveShortcut(monkey.Id);**
throw new MaxPinnedItemsException();
...
and could manage to Unpin all old Items from the List.
But that can not be a solution (especially for users of an app)
I can not add a screenshot, as the popup from the App Icon does disappear once I click on "Take screenshot"
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.