Display data in Toast Notification on Windows Phone 8.1 - windows-phone-8

I am generating XML payload for my Windows Phone 8.1 app using PHP,like this:
<toast launch=''>
<visual lang='en-US'>
<binding template='ToastText02'>
<text id='1'>".Input::get('your_msg')."</text>
</binding>
</visual>
</toast>
But my message is not getting displayed when toast notification pops up,notification just reads:
"<App name>: New notification"
Also,it is to be noted that I haven't used any toastTemplate code in my app.Any idea what's going wrong here?

I totally discarded this way and went with raw toast notifications.I had to do a little more work but now it works,how I want it to work exactly.

Related

Add notification to Windows notification center without displaying it on screen

I am building an Electron app featuring a custom Notification feature where html5 divs appear and disappear as needed on a frameless, transparent, always-on-top window.
It works great, but: I still like the Windows notification center itself, and would like to have the option to see the past notifications there, without actually displaying them on screen with the HTML5 api.
I have tried:
Looking into the HTML5 api for an option to not show a notification, or to .hide() it right away: no luck. The only method that comes close is .close(), and it removes the notification from the center as well.
Looking into packages like node-notifier, but none of the used notification dependencies offer a way to completely hide a notification.
While I mentioned Node, I will also accept any lower-level API/binding that would allow me to do this.
Thanks in advance.
With the help of #treckstar in comments, I have found a way to do what I wanted using:
NodeRT
The ToastNotification.SuppressPopup attribute
Despite a handful of troubles building NodeRT and using electron-rebuild, here's a working PoC:
const { XmlDocument } = require('#nodert-win10-rs4/windows.data.xml.dom');
const {
ToastNotification,
ToastNotificationManager
} = require('#nodert-win10-rs4/windows.ui.notifications');
const localImage = path.join(__dirname, 'icon.png');
const template = `
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<image id="1" placement="appLogoOverride" hint-crop="circle" src="${localImage}"/>
</binding>
</visual>
</toast>
`;
const xml = new XmlDocument();
xml.loadXml(template);
const toast = new ToastNotification(xml);
const notifier = ToastNotificationManager.createToastNotifier("com.myapp.testnotif");
toast.suppressPopup = true;
notifier.show(toast);
May this help whoever comes across the same highly-specific problem.
In addition to what #MadWard shows in the PoC, the suppressPopup key is really the main player of the solution.
As I was going through tons of examples and electron code I kept hitting roadblocks due to random SDK versions and libraries of things I had installed. For example, the package electron-windows-notifications, which uses NodeRT was failing to load my preload.js because the Windows 10 SDK I had installed (build 15063) needed nodert-win10-cu instead of what was being used in most solutions by default nodert-wind10-au.
SDK
Known As
Windows Version
npm Scope
Windows 10, Build 17134
April 2018 Update (Redstone 4)
1803
npmjs.com/org/nodert-win10-rs4
Windows 10, Build 16299
Fall Creators Update (Redstone 3)
1709
npmjs.com/org/nodert-win10-rs3
Windows 10, Build 15063
Creators Update (Redstone 2)
1703
npmjs.com/org/nodert-win10-cu
Windows 10, Build 14393
Anniversary Update (Redstone 1)
1607
npmjs.com/org/nodert-win10-au
Windows 10, Build 10586
Threshold 2
1511
npmjs.com/~nodert-win10
EDIT: I forgot to include the more specific steps I took getting electron-windows-notifications dependency files on this GitHub issue here. Basically everything from Python, broken node-gyp, and missing .winmd files.
Lastly Electron 14+ and NodeRT have an issue where you will need to make sure to have app.allowRendererProcessReuse = false and like the readme file says, to make sure this is running in the main.js file.
Hopefully this helps someone along the way, as I had never used Electron before until today and had learned a ton thanks to other peoples help.

WNS - Tiles are delivered and Toasts not

I have a big problem with the deliveration of Toast-Messages. The tiles are delivered as expeceted.
The first toast message I send to the device (with a new push URL) gets a resonse header with
X-WNS-NOTIFICATIONSTATUS: received
X-WNS-STATUS: received
but the toast is not delivered to the device.
If I send the toast another time the response from Microsoft looks like
X-WNS-NOTIFICATIONSTATUS: dropped
X-WNS-STATUS: dropped
X-WNS-ERROR-DESCRIPTION: Blocked channel URL
My HTTP-Requsest looks like this:
URL:
https://db5.notify.windows.com/?token=AwYAAAC5SQWdpe....25osxgpm3dB3zTN8io2OPMUIRs%3d
Header:
Content-Length: 102
X-WNS-Type: wns/toast
Authorization: Bearer EgAZAQMAA...
Content-Type: text/xml
Body:
<toast>
<visual>
<binding template="ToastText01">
<text id="1">bodyText</text>
</binding>
</visual>
</toast>
I hope someone can help me with this!
kind regards,
Bruno
Make sure you've set the Toast Capable option in your appx manifest to true first.
Check step 1 of this documentation: Enabling "Toast Notifications" for Windows 8 Store App or Visual Studio instructions here: Enabling "Toast Notifications" for Windows 8 Store App

Windows push notification service using Pushsharp giving Notification Failure

var push = new PushBroker();
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
push.RegisterWindowsPhoneService();
push.QueueNotification(new WindowsPhoneToastNotification()
.ForEndpointUri(new Uri(uri))
.ForOSVersion(WindowsPhoneDeviceOSVersion.Eight)
.WithBatchingInterval(BatchingInterval.Immediate)
.WithNavigatePath("/LandingView.xaml")
.WithText1("PushSharp")
.WithText2("This is a Toast"));
push.StopAllServices();
I am using pushsharp nuget package for push notifications and while passing uri to this c# backend code for windows, I am getting notification failure exception.
I am using the latest version of PushSharp (version 3.0) in a project of mine to send toast notifications to Windows Phone Devices and it is working fine for me. I notice by the code you have above that you are using an older version of the PushSharp package, there is a new 3.0 version available from nuget.
You could use that latest package to send toast notification to windows phone devices. The latest version of PushSharp uses the WNS as opposed to the old MPNS.
If you go to that nuget get link i supplied above and download the solution you can see some examples on how to implement the push notifcations for windows phone using WNS. Look under the PushSharp.Test project (look for the WNSRealTest.cs file).
Below is an example of how you can send a toast notification to windows phone device:
var config = new WnsConfiguration(
"Your-WnsPackageNameProperty",
"Your-WnsPackageSid",
"Your-WnsClientSecret"
);
var broker = new WnsServiceBroker(config);
broker.OnNotificationFailed += (notification, exception) =>
{
//you could do something here
};
broker.OnNotificationSucceeded += (notification) =>
{
//you could do something here
};
broker.Start();
broker.QueueNotification(new WnsToastNotification
{
ChannelUri = "Your device Channel URI",
Payload = XElement.Parse(string.Format(#"
<toast>
<visual>
<binding template=""ToastText02"">
<text id=""1"">{0}</text>
<text id=""2"">{1}</text>
</binding>
</visual>
</toast>
","Your Header","Your Toast Message"))
});
broker.Stop();
As you may notice above the WnsConfiguration constructor requires a Package Name, Package SID, and a Client Secrete. To get these values your app must be registered with the Store Dashboard. This will provide you with credentials for your app that your cloud service will use in authenticating with WNS. You can check steps 1-3 on the following MSDN page for details on how to get this done. (note in the link above it states that you have to edit your appManifest.xml file with the identity of your app, I did not do this step, just make sure you have your windows phone app setup correctly to receive toast notification, this blog post will help with that.
Hope this helps.

Error 0X800455BC when creating a SpeechRecognizer object on Windows Phone 8.0?

My Lumia 820 is running Windows Phone 8.0. My Lumia 520 is running Windows Phone 8.1 developer preview. Speech reco works fine on the Lumia 520, but with the 820 I get a System.Exception with an HRESULT code of 0x800455BC. I did some research and that error is supposed to be localization related. It happens when the language your phone is set to is not supported by the speech recognizer:
Exception HRESULT: 0x800455BC in speech recongnition in Windows phone 8
Except I am not getting the same call stack as what that page shows. Also, the solution offered on that page says I should set my recognizer to the desired language explicitly. But that's a problem since I get the error when I create the recognizer. Since I can't create it, I can't set the language. Other people get the error when they try to do a speech recognition session.
Note, I definitely have enabled speech recognition via the phone settings, even allowing it when the phone is locked. Have any of you seen this and know what to do about it? I get the error right when I try to construct the SpeechRecognizer object:
// Create the recognition engine.
this.SpeechRecognizerObj = new SpeechRecognizer();

Windows Phone 8 AdControl AdException?

I've been testing a new Windows Phone 8 app for the last couple of weeks. I haven't yet published it to the Store yet, so I've only tested my AdControls with test values (i.e. "test_client" and "Image480_80").
I noticed the other day as soon as I launch my app, I see the AdControl for a second, and then it disappears. No error is thrown on the app's interface, but in the Output window I can see the following exception:
An exception of type 'Microsoft.Advertising.Shared.AdException'
occurred in Microsoft.Advertising.Mobile.DLL and wasn't handled before
a managed/native boundary
Here is the stack trace:
at
Microsoft.Advertising.Shared.AdvertisementFactory.CreateFromResponse(String
response, AdDownloadCompleteCallback adDownloadCompleteCallback)\r\n
at Microsoft.Advertising.Shared.AdPlacement.CreateAdvertisement(Byte[]
bytes)\r\n at
Microsoft.Advertising.Shared.AdPlacement.AdRequestComplete(IWebRequestWrapper
request)
Here is my code which adds the AdControl to my Grid:
AdControl adControl = new AdControl("test_client", "Image480_80", true);
adControl.Width = 480;
adControl.Height = 80;
adControl.ErrorOccurred += AdUnit_ErrorOccurred;
MyGrid.Children.Add(adControl);
Grid.SetRow(adControl, 4);
Grid.SetColumn(adControl, 4);
This was working fine up until a few days ago, so I'm not sure if the code needs to change but is there anything else I can check? I saw an article that said to make sure I've got the required capabilities in my WMAppManifest.xml file. Here's what I've got currently:
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
<Capability Name="ID_CAP_PHONEDIALER" />
</Capabilities>
Does anyone know of anything else I can check - or know what I may be doing wrong? I'm really stumped. If there's anything else I can post from my Exception object (in addition to the stack trace above) please let me know, although I didn't see anything that hinted at a possible problem.
UPDATE:
I can also confirm that using my actual ApplicationID and AdUnitID in place of the test values that the exact same thing happens. Has anyone else experience this?
UPDATE 2:
I've been emailing back and forth with PubCenter Support, and they've apparently been able to replicate the problem because the analyst helping me (Support Analyst II) has now engaged the engineering team to look into the problem. There is no ETA on a resolution but they said using my actual ApplicationID and AdUnitID should work when testing on an actual device (although I already confirmed it does not work in my emulator).
UPDATE 3:
I'm still waiting to hear back from PubCenter Support, but I have now confirmed that Ads DO WORK successfully if I use the real ApplicationID and AdUnitID. Previously, I thought this didn't work, but it appears it only doesn't work when running in the emulator - on the device itself, they work fine. So it is only test ads that don't seem to work, and since that's the case, I'm not too worried about it.
UPDATE 4 (SOLUTION):
OK - After weeks of back and forth with PubCenter Support I finally have a solution, although I'm pretty sure it was an issue on their end that is now resolved. I had created a very simple test solution which demonstrated my problem that I sent to them and they finally concluded that this:
AdControl adControl = new AdControl("Test_client", "Image480_80", true);
Needed to be this:
AdControl adControl = new AdControl("test_client", "Image480_80", true);
To find out more specific error information, you can inspect the AdErrorEventArgs passed to the AdControl.ErrorOccurred event you've already registered. If it's still not clear from that information, please add the error/error code to your question.
The reason I've seen this exception show up is that there are no ads to display (ie you've specified a too narrow selection of ads to display and there are no matching ones available), but that should in that case be clear when you view the error.
Apparently, this:
AdControl adControl = new AdControl("Test_client", "Image480_80", true);
Needed to be this (note the lowercase "t" in test_client):
AdControl adControl = new AdControl("test_client", "Image480_80", true);
Who would have thought?
I have the same problem. The ads in my WP7.5 app work in both the emulator and the phone. When I upgrade my app to WP8 the ads stop working. So, I added a second ad provider control to my app and made it so that if MS ad control gets an error it hides and displays the 2nd ad from a different company.