how to get my device token in nokia lumia 630 - windows-phone-8

Basically I am PHP developer! and now I want to implement the push notifications for windows phone! So for this I have refereed many blogs and also started implement on this! but for demo purpose how I can get my device token and device specific type of my phone that having Windows 8.1 OS.
Is any GUI tool for getting this.

If you need the Device Token as follows-
Byte[] DeviceArrayID = (Byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string UniqueDeviceID = Convert.ToBase64String(DeviceArrayID);
Debug.WriteLine("Device ID - " + UniqueDeviceID
Also, if you need help regarding push notifications in Windows Phone apps, follow this link-
http://msdn.microsoft.com/en-us/library/windows/apps/hh202967%28v=vs.105%29.aspx
It also has a project for a simple webpage which can send notification to your device for testing purposes.

The following should work
object DeviceUniqueID;
byte[] DeviceIDbyte = null;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out DeviceUniqueID))
DeviceIDbyte = (byte[])DeviceUniqueID;
string di = Convert.ToBase64String(DeviceIDbyte);
The above code will give you the device ID. You can use the string di to pass the Device ID to your web service to provide the user with push notifications.

Related

Flutter send push notifications using fcm for all devices

How are you guys , my problem that my flutter app is connected to mysql db , when the user is registered a string with the class name is saved to shared preferences and there is a wall to post some posts on it , is there any way to work with fcm bassed on the shared preferences string ? Like if the user has this string and posted let all users with the same string get notifications i hope i could make it more uderstandable but i dont know how ! Thanks
This sounds like a perfect use-case for using topics to target those messages. Step-wise:
Each device subscribes to the topic based on their class. If they can have multiple classes, they'd subscribe to all topics for those classes.
You then send the message to the correct topic for its class, and FCM will deliver it to all devices subscribed to that topic.
As usual, you will need to perform the actual send operation from a trusted environment, such as your development machine, a server you control, or Cloud Functions.
you will get the token id from the device which you can store to the user table so it will use while giving the notification to every device.
For getting the token :
_firebaseMessaging.getToken().then((String token) {
assert(token != null);
setState(() {
_homeScreenText = "Push Messaging token: $token";
});
print(_homeScreenText);
});
this token variable which you can store to the user table and use it while giving the notification to every device.

Get Device Model in windows Phone 8.1 Runtime

is there a way to retrieve friendly device model in windows phone 8.1?
EasClientDeviceInformation a = new EasClientDeviceInformation();
String b = a.SystemProductName; // RM-994 not lumia 1320
this Api doesn't return device friendly name.
No way to get a friendly name like Lumia 1320 directly from the API, you need to use https://github.com/ailon/PhoneNameResolver to convert the name from API (RM-994) to the friendly name.

How to store user data in window phone 8 app?

Please help me how to store user data in window phone 8 application?
I have a plan to develop an application on windows phone 8 which allow user create xml file to store their private data. The question is how to store user data on window 8.1 phone. After search solution, i know that
+ Isolated Storage can store data but it just small data for application
+ Store data on SD card is read only.
So, is there any other way to store data?
Thank and sorry about my english skill!
ApplicationData (LocalFolder on WP8 or LocalFolder and RoamingFolder on WP8.1) is designed for what you are trying to do. The ApplicationSettings themselves are better for small pieces of data, but apps can save files of any size which the phone has room for in the LocalFolder.
See Accessing app data with the Windows Runtime on MSDN for details. While the docs target Windows Runtime apps, the ApplicationData and StorageFile API are available to Silverlight apps on Windows Phone 8 and later.
Additional Usings:
using System.Xml.Serialization;
using Windows.Storage;
using System.IO;
Code:
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile saveFile = await localFolder.CreateFileAsync("data.xml", CreationCollisionOption.ReplaceExisting);
using (var ras = await saveFile.OpenAsync(FileAccessMode.ReadWrite))
{
Stream stream = ras.GetOutputStreamAt(0).AsStreamForWrite();
XmlSerializer serializer = new XmlSerializer(typeof(List<Book>));
serializer.Serialize(stream, data);
}
If you need more structured data than XML then you can store a SQLite database in the local folder. If you need more space than is reasonable for an app to store on the device then you'll need to move it to a web service. Azure Mobile Services is a good place to do that. You can call such a service from a Windows Phone Silverlight app, but the wizards will generate Universal apps.

How to get the Application Process ID in Windows Phone 8.1 Store Apps

I am developing a Windows Phone 8.1 Application and there is a need to get the Application Process ID from code. Any API with which I can get that?
You can use GetCurrentProcess followed by DuplicateHandle (and later CloseHandle) but I'm curious what you need it for... there's not much you can do with it in a Store app so maybe this won't complete your scenario.
Finally got the solution.
The Dll's for Desktop apps and Phone apps are different though the function names will be same.
When tried to import Kernal.dll lib in WIn Phone 8.1 and used p/invoke code, an exception, DllNotFoundException will be thrown. Instead in Win Phone 8.1 instead use "api-ms-win-core-processthreads-l1-1-1.dll"
To get the process ID in Win Phone 8.1 :
1)Create binding to WIN32 lib:
[DllImport("api-ms-win-core-processthreads-l1-1-1.dll", CharSet = CharSet.Unicode, ExactSpelling = false, PreserveSig = true)]
internal static extern uint GetCurrentProcessId();
2)Call the function:
uint id= GetCurrentProcessId();
For the complete set of Win Phone 8 supported API's see the MSDN link:
https://msdn.microsoft.com/library/windows/apps/jj662956(v=vs.105).aspx#BKMK_ListofsupportedWin32APIs

How to get a query string in a windows phone 8.1 app?

Sorry to ask such a basic question, but I've spent the last 30mins on google and found nothing (very likely my poor search engine skills!)
I'm upgrading (well, moving code) from a windows phone 8 app to a universal app (the windows store code is largely absent at the moment, I'm currently concentrating on porting over the windows phone stuff).
Previously I was using
NavigationContext.QueryString.TryGetValue
But with 8.1 this doesn't work and I can't for the life of me find out how to get the querystring.
Any help would be very gratefully appreciated.
You can send a parameter the way Vyas_27 written, but make it looks like
//id - first parameter
//value - second parameter
Frame.Navigate(typeof(SecondPage), "id&value");
To get parameters
string[] parameters = ((string)e.Parameter).Split(new char[] {'&'});
string id = parameters[0];
string value = parameters[1];