httpnotificationchannel same ChannelUri from two different apps in emulator - c#

I'm new to windows phone development and have started working with push notifications within the emulator in visual studio 2012. We are having a strange problem where we have two apps in visual studio and when we start each one and call the following:
CurrentChannel = HttpNotificationChannel.Find("ChannelName");
if (CurrentChannel == null)
{
CurrentChannel = new HttpNotificationChannel("ChannelName");
CurrentChannel.Open();
CurrentChannel.BindToShellTile();
CurrentChannel.BindToShellToast();
}
Even though the ChannelName is different in each app the CurrentChannel.ChannelUri is the same so when we send push notifications they only go to one app.
I am sure we are missing something very obvious or misunderstanding the way this is supposed to work but any insight would be appreciated.

I supposed you didn't get the right Uri according to your piece of codes. Try to Listen on ChannelUriUpdated event to get a fresh Uri.
If you did, maybe try it on a real device, emulator is not always to be trusted enough.
And Push notification channel URi is unique for device & app combination, to be sure you made something different in these two apps. Anyway seems this couldn't be happened.

Related

iOS doesn't open Zoom app using Xamarin Essentials Launcher.OpenAsync

My xamarin.forms app is meant to join a Zoom meeting on a mobile device using Launcher.OpenAsync() with a uri scheme of the form "zoomus://zoom.us/join?confno=1234567890&pwd=123456".
This works fine on Android, but on iOS it doesn't seem to do anything at all. I call Launcher.CanOpenAsync() beforehand, and that returns true, so the uri should be OK. The Zoom app is already installed. In info.plist I have added zoomus (and zoom) to LSApplicationQueriesSchemes.
My code looks like this:
private void RunZoomAsync()
{
Task zoomTask = Task.Run(async () =>
{
if (await Launcher.CanOpenAsync(selectedMedia.Uri))
{
Message = "Launching Zoom";
await Launcher.OpenAsync(selectedMedia.Uri).ConfigureAwait(false);
}
else
{
Message = "Zoom not found. You must install Zoom from your App Store";
}
});
}
I see the message on the screen, so I know it's getting to the right bit of code.
I tried sending the same link to the iPhone in an email and that does nothing either. (I tried that on the Android phone, and the email app wouldn’t even display the link as a hyperlink). Is there some setting on the iPhone, or in my app, to allow deep linking?
As you may have guessed, I am not normally an iPhone user. I’m using an old iPhone 6 for testing, running iOS 12.4.8.
I have sought help from the Zoom developer forum, who suggested that when using url schemes in iOS, there is an AppDelegate function that needs to be overridden:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
I'm guessing the above is not C#, and that the Essentials Launcher class deals with whatever is required in iOS.
Am I missing something, or is this a bug? Any help gratefully appreciated.
I tried sending the same link to the iPhone in an email and that does
nothing either. (I tried that on the Android phone, and the email app
wouldn’t even display the link as a hyperlink). Is there some setting
on the iPhone, or in my app, to allow deep linking?
This needs to work if you have installed the app and if you are using the proper protocol and if your hardware and operating system is working properly. Your problem is not caused by your code (well unless you are using the wrong protocol), so this is the answer for this site as it doesn't deal with non-coding problems.
Why your Zoom app is not working as expected - you should start with the Zoom customer support as they are in the best position to give you the answer if it exists, but it is extremely likely that your device is faulty in some way.
My problem was that I wasn't running the Launcher in the main thread, so (I assume) the Zoom app didn't have access to the screen. So I just changed:
Task zoomTask = Task.Run(async () =>
to:
MainThread.BeginInvokeOnMainThread(async () =>
and it's now working!

How to scan for another device through Bluetooth- Xamarin

I'm developing Xamarin application using Visual Studio 2019. I have to connect to another device through Bluetooth and send some data and receive acknowledgement back. Tried these two samples out
https://github.com/msthrax/BLEApp
and
https://github.com/didourebai/BLEPluginDemo.
But didn't help me while scanning for nearby Bluetooth devices, since the below codes are not giving expected result respectively..
1.
listView_DeviceList.ItemsSource = CrossBluetooth.Adaptor.GetListOfDiscoveredDevices();
and
2.
adapter.DeviceDiscovered += (s, a) =>
{
deviceList.Add(a.Device);
};
Both Bluetooth and location turned on in my devices. Can anyone let me know the possibilities of problem here. I don't have any build errors in both of the above samples. Whereas, I have one surprise also. Below line is giving proper result, which is of no use for me currently.
listView_PairedDeviceList.ItemsSource = CrossBluetooth.Adaptor.GetPairedDevices();
After enabling the Location Permission for the app(earlier, I turned on Device Location, but we should allow the app to get device location), all my above problems are solved out.

extendedExecutionSession : Can we run UWP like Desktop app without Suspending?

I'm planing to start a UWP application that monitor a sensor data for 365 days and save all data to database(Sqlite).
I still worry about UWP capability. Please advice me Which should I use (UWP/WPF) ? I want to use better UI, than, I want to use UWP if possible...
UWP-Suspending is my worry.
With this post, Some people said a way to prevent a UWP application from suspending..
var extendedExecutionSession = new ExtendedExecutionSession();
extendedExecutionSession.Reason = ExtendedExecutionReason.Unspecified;
var extendedExecutionResult = await extendedExecutionSession.RequestExtensionAsync();
if (extendedExecutionResult != ExtendedExecutionResult.Allowed)
{
//extended execution session revoked
extendedExecutionSession.Dispose();
extendedExecutionSession = null;
}
Question
If I wrote this code in UWP app, Can I use a UWP application like Desktop WPF application ? I want to run my UWP application for 365 days without stopping
.. even if user do "minimized" on desktop... Please advice it...
Yes, you can do that with ExtendedExecution. One thing to note is when you run on battery (e.g. laptop, tablet) you will get suspended after some time - however you can prevent that as well by going into the Battery settings page and set your app as "Always Allowed".
Details are documented here: https://learn.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution

How to troubleshoot remote UWP AppService problems?

I'm playing around with remote UWP AppServices in C# and I run into a very early roadblock: Getting a RemoteSystem instance.
I followed the tutorial on https://msdn.microsoft.com/en-us/windows/uwp/launch-resume/communicate-with-a-remote-app-service with my own code and I tried out the RemoteSystems sample as part of https://github.com/Microsoft/Windows-universal-samples
Unfortunately, the result is always the same.
First I request access to remote systems:
RemoteSystemAccessStatus status = await RemoteSystem.RequestAccessAsync();
This is successful: status has the value RemoteSystemAccessStatus.Allowed.
Next, I create a HostName instance:
var deviceHost = new HostName("computer2");
Then I want to get a RemoteSystem instance:
RemoteSystem remoteSystem = await RemoteSystem.FindByHostNameAsync(deviceHost);
This throws an exception:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
What I tried
Searching the web doesn't bring up much at this time (remote UWP AppServices are too new)
The event log doesn't have anything interesting in it
The Windows firewall seems to be configured correctly (this seems to be done automatically by Visual Studio)
What I'm looking for
One of my computer was upgraded from Windows 7 to Windows 10, the other from Windows 8.1 to Windows 10. So there is a chance my computers are "misconfigured" in some way (I remember the unnecessary task scheduler entries for Windows Media Center...)
My question: What are recommended practices to troubleshoot these kinds of problems? Are there tools that can help me? Right now I'm now even sure where to start looking...

How can I configure network access for the Windows Phone emulator?

I'm trying to debug an application that is making a WebRequest synchronously, ie.:
HttpWebRequest req = WebRequest.Create(new Uri("http://www.stackoverflow.com/")) as HttpWebRequest;
IAsyncResult res = req.BeginGetResponse(callback => { }, req);
while (!res.IsCompleted)
{
System.Threading.Thread.Sleep(100);
}
// Doesn't matter what's here, as `res.IsCompleted` never returns true
This is just to check that some of the application logic is "right", but it's getting stuck, with the IAsyncResult never reporting itself as complete.
To check, things, I tried to use Internet Explorer on the emulator, but found that is unable to find any webpages (including the built in favourites), which makes me think that the emulator is trying to use a specific network interface on my laptop, but there doesn't seem to be any way to configure it, or which interface to use? I have a suspicion that it may be trying to use a VPN interface, or a virtual adaptor like the one for VirtualBox. So, how can I configure it? additionally, would you expect requests made by the emulator to show up in Fiddler?
For the record, NetworkInterface.GetIsNetworkAvailable() returns true;
UPDATE:
It appears that updating my graphics driver (and associated reboot) allowed the emulator to access the real network (or at least guess the right adapter); however, res.IsCompleted still doesn't report true (and Fiddler shows the request has completed), so I'm a little confuddled.
Are you using a proxy? The Windows Phone emulator is tied to the currently active Internet Connection, as well as the proxy settings. Make sure those are set up correctly. Also, there might be a firewall blocking Internet access for XDE - check the settings too.
I would recommend getting Fiddler. Attempt to configure it to capture emulator traffic and see what information you can get from there.

Categories