how to create push notification channel in windows phone 8.1 - windows-phone-8.1

HttpNotificationChannel class is running in windows phone 8.0 but it is not running in windows phone 8.1 why .
Is there any alternative for windows phone 8.1?

check here
PushNotificationChannel channel = null;
try
{
channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
Debug.WriteLine("Channel :: " + channel.Uri.ToString());
}
catch (Exception ex)
{
// ...
}

Related

web serial api shows "no compatible devices found" despite being given the vendorId

Windows 8.1, Chrome v91.0.4472.164. I have verified the vendor and product ids against the device manager. The device is a Arduino UNO using the Ch340 driver, it is listed in the device manager under Ports(COM & LPT) as "USB-SERIAL CH340(COM7)"
My code looks like this;
try {
const requestOptions = {
filters: [{
usbVendorId: 0x1A86,
usbProductId: 0x7523
}]
};
const device = await navigator.serial.requestPort(requestOptions);
} catch (e) {
console.log(e);
return;
}
I wonder if usbProductId and usbVendorId are wrong somehow ;(
Can you try this snippet of code which will allow you to get a prompt, select the Arduino UNO device serial port, and check usbProductId and usbVendorId?
const port = await navigator.serial.requestPort();
const { usbProductId, usbVendorId } = port.getInfo();
console.log({ usbProductId, usbVendorId });

Google Login in Windows Phone 8.1

I'm trying to use Google Apis for login in Windows Phone 8.1.
I have this method:
public async Task<bool> AuthenticateAsync()
{
var Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new Uri("ms-appx:///Shared/Jsons/client_secrets.json"),
new[] { PlusService.Scope.PlusLogin},
"user",
CancellationToken.None);
System.Diagnostics.Debug.WriteLine($"Credential: {Credential}");
var loginSuccess = await NetworkManager.LoginWithGoogle(Credential.Token.AccessToken);
return loginSuccess;
}
Everything after GoogleWebAuthorizationBroker.AuthorizeAsync() is not executed.
Also if i try to debug i put breakpoint on that instruction and when i go further i see the app going out of that method, without execute all the other instructions.
I have no exception and so i don't know why.
Some hint?

How to get Google API access code using Code in windows phone 8.1 App?

I am new in Windows phone application development.
I have created my app in Google developer Console.
From my windows phone application I am using "webview" to render the Google login page and with successfull login I got a code like: 4/akd.........
Can anyone tell me how to access the code using "code" first time ?
I have try by following way :
public void GetProfileDetail(string code)
{
StringBuilder authLink = new StringBuilder();
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://accounts.google.com/o/oauth2/token");
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
authLink.AppendFormat("code={0}", code);
authLink.AppendFormat("&client_id={0}", clientId);
authLink.AppendFormat("&client_secret={0}", clientSecret);
authLink.AppendFormat("&redirect_uri={0}", redirect_url);
authLink.Append("&grant_type=authorization_code");
UTF8Encoding utfenc = new UTF8Encoding();
byte[] bytes = utfenc.GetBytes(authLink.ToString());
Stream os = null;
try // send the post
{
//webRequest.ContentLength = bytes.Length; // Count bytes to send
os = webRequest.GetRequestStreamAsync().Result;
os.Write(bytes, 0, bytes.Length); // Send it
}
catch (Exception ex)
{
}
}
but it gives me an error. Let me know what to do next
Thanks in advance.
You are trying to do the OAuth authentication through the webview, but that is not the recommended way to go.
Since wp8.1 there is a WebAuthenticationBroker class that you can use to initiate an OAuth process with a provider ( like Google in your case ).
A good detailed example can be found on MSDN here https://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122

How to exit an application on Windows Phone 8 programmatically

I am creating an application in which when i press the cancel button the application should close.
for that I have used " navigator.app.exitApp()" statement as given a solution in stack overflow.
This solution is working in android but it is not working in windows phone 8.
Windows phone is throwing exception that "Unable to get property 'exitApp' of undefined or null reference"
I have written following code for this.
cancelLogin: function () {
var result = DevExpress.ui.dialog.confirm('Do you want to exit ?', 'Confirm Exit');
result.done(function (dialogResult) {
try {
if (dialogResult === true) {
navigator.app.exitApp();
}
}
catch (e) {
DevExpress.ui.dialog.alert(e.message, 'Exception');
}
});
}
this works fine in android but not working in windows phone.
how can I close an application programetically in windows phone 8 ??
The exitApp method is not supported by Cordova APIs for Windows Phone 8. To solve the problem, please execute the following code for the Windows Phone 8 platform:
window.external.Notify("DevExpress.ExitApp");
If you create a Windows Phone application using the DevExtreme wizard, the required code will be automatically generated.
if(device.platform === "win8" && device.phone) {
defaultLayout = "simple";
startupView = "Navigation";
$.each(Application1.config.navigation, function (i, item) { item.root = false; });
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false);
}
function onBackKeyDown() {
if(Application1.app.canBack()) {
Application1.app.back();
}
else {
if(window.external) {
window.external.Notify("DevExpress.ExitApp");
}
}
}
Thanks,

Location of folders created in Windows Phone 8

Where do I find the location of the folders and text files I created in windows phone 8. Can we see it in the explorer like we search for the app data in Windows 8? I'm not using IsolatedStorage, instead Windows.Storage. I want to check if the folders and files are created as I want.
This is how I write the file
IStorageFolder dataFolder = await m_localfolder.CreateFolderAsync(App.ALL_PAGE_FOLDER, CreationCollisionOption.OpenIfExists);
StorageFile PageConfig = null;
try
{
PageConfig = await dataFolder.CreateFileAsync("PageConfig.txt", CreationCollisionOption.OpenIfExists);
}
catch (FileNotFoundException)
{
return false;
}
EDIT
try
{
if (PageConfig != null)
{
using (var stream = await PageConfig.OpenStreamForWriteAsync())
{
DataWriter writer = new DataWriter(stream.AsOutputStream());
writer.WriteString(jsonString);
}
}
}
catch (Exception e)
{
string txt = e.Message;
return false;
}
And this is how I read the file from the folder
try
{
var dataFolder = await m_localfolder.GetFolderAsync(App.ALL_PAGE_FOLDER);
var retpng = await dataFolder.OpenStreamForReadAsync("PageConfig.txt");
if (retpng != null)
{
try
{
using (StreamReader streamReader = new StreamReader(retpng))
{
jsonString = streamReader.ReadToEnd();
}
return jsonString;
}
catch (Exception)
{
}
}
}
catch (FileNotFoundException)
{
}
There are also other folders created. I dont receive any exceptions while writing but when I read the string is empty.
Windows.Storage.ApplicationData.LocalFolder(MSDN link here) is another name for Isolated Storage that is in Windows.Storage namespace. The only other location you can access is your app's install directory (and only read-only).
You can use Windows Phone Power Tools to browse what files are in your app's Isolated Storage, or the command line tool that comes with the SDK.
With the help of Windows Phone Power tools, I figured out that there was no text being written in file.
So I converted string to byte and then wrote it to the file and it works! Don't know why the other one does not work though..
using (var stream = await PageConfig.OpenStreamForWriteAsync())
{
byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(jsonString);
stream.Write(fileBytes, 0, fileBytes.Length);
}
The command line tool that comes with Windows Phone SDK 8.0 is Isolated Storage Explorer (ISETool.exe) which reside in "Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\IsolatedStorageExplorerTool" folder for default installation
ISETool.exe is used to view and manage the contents of the local folder