i am facing a weird problem. I am using Windows phone 8.1 silverlight and Windows universal link for toast notification. I am able to get the toast notification in Windows Phone app it is nearly same way in Windows 8.1 as mentioned in the link. But toasts are not comming in Windows 8.1 part.
Steps :-
1 -> I have enabled the Toast from Package.appxmanifest file.
2 -> Then i have added this code in App.Xaml.cs in on_launched event as mentioned
It is showing the registeration successful as mentioned in the link
private async void InitNotificationsAsync()
{
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var hub = new NotificationHub("<hub name>", "<connection string with listen access>");
var result = await hub.RegisterNativeAsync(channel.Uri);
// Displays the registration ID so you know it was successful
if (result.RegistrationId != null)
{
var dialog = new MessageDialog("Registration successful: " + result.RegistrationId);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
3 -> Now i send the notification from back end(Hub is working in case of phone mpns notification).
public static async void SendNotificationAsync()
{
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("<connection string with full access>", "<hub name>");
var toast = #"<toast><visual><binding template=""ToastText01""><text id=""1"">Hello from a .NET App!</text></binding></visual></toast>";
await hub.SendWindowsNativeNotificationAsync(toast);
}
Question : -
Do you guys have a clue why it is not working in Windows 8.1 or what i am missing. This is the simplest example i am going through. Any help is appreciated.
Edit :- This is something interesting.
When i tried to send the notification from azure portal. From DEBUG tab of My-NotificationHub and from here i choose WNS toast then it showing an error.
Error - The token obtained from the token provider is wrong
but when i tried to send MPNS notification then there is no error. as i already mentioned it is working for WP 8.1 silverlight MPNS toast.
What could be the cause of this error ?
Toast will not work on simulator, as stated in the MSDN documentation:
Note When testing toast notification code functionality through
Microsoft Visual Studio, you must use either the Local Machine or
Remote Machine debug setting on a Windows x86, x64, or Windows Runtime
machine. You cannot use the Visual Studio Simulator debug function
option—your code will compile and run in the Simulator, but the toast
will not appear.
Source: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868254.aspx
If I remember correctly on Windows 8 the toast notifications did not work when I was using the simulator. I had to deploy my Windows 8 application on my computer and not the simulator for me to be able to see toast notifications.
Related
To launch another specific app we can set the other app's package family name:
var options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = packageFamilyName;
Uri uri = new Uri(protocol);
var succeeded = await Windows.System.Launcher.LaunchUriAsync(uri, options);
If the other app wasn't installed, Store download page opens. But this happens only on Windows 10 desktop, on the phone nothing happens, it just fails.
However if we remove options parameter it searches for any app on Store.
await Windows.System.Launcher.LaunchUriAsync(uri);
Is there anyway to have Desktop behavior on Mobile too? I mean open exactly a specific app not any app that registered for that protocol
The documentation states this is for Desktop only at this point in time. Potentially the feature will make it to Mobile (and other Windows flavours) in the future.
I am using Xamarin Forms and am currently trying to get push notifications to work with the iOS project. I have followed this Xamarin guide to add notifications to my iOS app but the RegisteredForRemoteNotifications method is never called.
I have also created both push notification certificates and enabled background notifications. Even FailedToRegisterForRemoteNotifications is never called.
What can I do?
PS: I'm using an iPhone 5s with iOS 10 so I also read this post on the User Notifications Framework.
Points for noticing the big note at the top of the Xamarin guide, a lot of people sometimes gloss over them.
NOTE: The information in this section pertains to iOS 9 and prior, it
has been left here to support older iOS versions. For iOS 10 and
later, please see the User Notification Framework guide for supporting
both Local and Remote Notification on an iOS device.
It would have been nice to see some of your own code sample, but that's neither here nor there.
So as you said you plan on using iOS 10 devices, here is the code we use that works from 10.3 backwards.This code is in our FinishedLaunching() method inside the AppDelegate class.
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// iOS 10 or later
var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
{
if (granted)
{
InvokeOnMainThread(() => {
UIApplication.SharedApplication.RegisterForRemoteNotifications();
});
}
});
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.Current.Delegate = ADSelf;
}
else
{
// iOS 9 or before
var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
}
The key really is the following lines:
UIApplication.SharedApplication.RegisterForRemoteNotifications();
OR
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
You cannot register the device if it is a simulated device.
So, after publishing in the AppStore it starts working...
I was having the same issue. The fault was, the mobile phone didn't have an active internet connection!
We're building a multi-platform (desktop- and tablet-computers) application targeting Windows 8.1 as well as 10. As we process spatial data, we offer the user the possibility to use his current location using the device's gps receiver. To allow easy adaption to the (hardware) environment, we placed the gps-logic (including the API-calls) into an external assembly that we load based on a configuration.
Recently we discovered some problems with the gps-module using the Geolocator from Windows.Devices.Geolocation-API under windows 10 (but previously running without problem on Windows 8.1), not delivering any location. Further investigation and RTFM showed up, that - under Windows 10 - we were obliged to call the RequestAccessAsync before calling for the location.
As the RequestAcessAsync-method isn't available in Windows 8.1, we decided to create a new assembly, targeting Windows 10 (and then easily being bound/used through our configuration), what worked quite well:
public Win10GpsProvider()
{
RequestAccessAsync();
}
public async void RequestAccessAsnyc()
{
//next line causes exception:
var request = await Geolocator.RequestAccessAsync();
switch (request)
{
// we don't even get here... :(
}
}
Only up to running into an exception that gets thrown as soon as the RequestAccessAsync-method is being called (in UI-thread), stating that the call has to be made in the context of an app container.
This operation is only valid in the context of an app container. (Exception from HRESULT: 0x8007109A)
The exception occurs on both, desktop as well as tablet (verified through remoted debugging).
Searching a bit more, adding the "location" as a required capability to the package.appxmanifest may help:
<Capabilities>
<Capability Name="location"/>
</Capabilities>
That's where we're actually stuck at the moment:
We don't have an UWP-application (and actually don't want/can change that, as we're targeting Win 8.1 as well and have a defined deployment workflow including setups)
We can't get the assembly run without exception as there is no UWP app/context
Is there a way to get a separate assembly that targets the Windows 10 version of the Windows.Devices.Geolocation-API and can be called/loaded by a Win32-application?
AFAIK, it is not doable to call RequestAcessAsync method and make it work in Windows 8.1 app.
But if you directly use Geoposition in windows 8.1 project, and run this windows 8.1 app on windows 10 device for example on desktop, the permission request dialog will also be displayed:
So there should be no problem if you don't call RequestAcessAsync method in windows 8.1 app.
But in case user choose "No" in this permission request dialog, we can catch the exception and launch the Setting page to force user to enable the Location setting for this app for example like this:
private Geolocator _geolocator = null;
private uint _desireAccuracyInMetersValue = 0;
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
try
{
var _cts = new CancellationTokenSource();
CancellationToken token = _cts.Token;
_geolocator = new Geolocator { DesiredAccuracyInMeters = _desireAccuracyInMetersValue };
Geoposition pos = await _geolocator.GetGeopositionAsync().AsTask(token);
// Subscribe to PositionChanged event to get updated tracking positions
_geolocator.PositionChanged += OnPositionChanged;
// Subscribe to StatusChanged event to get updates of location status changes
_geolocator.StatusChanged += OnStatusChanged;
}
catch (Exception ex)
{
await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
}
}
This code in windows 8.1 project works fine both on windows 8.1 device and windows 10 device. And I don't quite understand what is your Win32-application for here?
I am developing a chat app in windows phone 8.1. I am using MQTT to communicate.It works fine when my app is in foreground.But I am facing two problems.
1) I am unable to get messages from sender when network is lost and reconnected.
2)I am unable to get messages from sender when I open the app which was sent in app inactive stage.
I am using this code to communicate:
client = new MqttClient("myhostname", 1883, false);
string id = Guid.NewGuid().ToString();
client.Connect(id);
The above cases works fine in android am I doing wrong ?? Please help me to solve.
Thanks,
Srinivas
I have an exception only in one PC, in others all work fine, anyone know wher it is comming from?
dditional information: Requested Windows Runtime type
'Windows.Media.Capture.MediaCapture' is not registered.
This exception is showing only in modern style apps (windows strore app) in windows 8.1. In WPF or Windows Form apps camera works fine. Code is fine, because in other pc work great:) i install system one more time, but the exception still showing up.
Looking at Microsoft's Windows Universal Samples (https://github.com/Microsoft/Windows-universal-samples/blob/e13cf5dca497ad661706d150a154830666913be4/Samples/SpeechRecognitionAndSynthesis/cs/AudioCapturePermissions.cs#L35) shows following piece of code
try
{
// Request access to the microphone only, to limit the number of capabilities we need
// to request in the package manifest.
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
settings.MediaCategory = MediaCategory.Speech;
MediaCapture capture = new MediaCapture();
await capture.InitializeAsync(settings);
}
catch (TypeLoadException)
{
// On SKUs without media player (eg, the N SKUs), we may not have access to the Windows.Media.Capture
// namespace unless the media player pack is installed. Handle this gracefully.
var messageDialog = new Windows.UI.Popups.MessageDialog("Media player components are unavailable.");
await messageDialog.ShowAsync();
return false;
}
So you have to install "Media player components".
I just had this issue with Windows 10. I had installed the N edition, but it looks like since it is missing Media Player, the classes related to MediaCapture are also missing.
As Hans Passant mentioned, the MediaCapture class was not registered in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId.
I reinstalled Window 10 (not the N edition) and now the class is registered.