Windows Phone 8 Restore In App Purchase on different device - windows-phone-8

My app is for Windows Phone 8. I don't get in app purchases on other device configured with same account. On the start of app I am trying to restore purchases. Below is the snippet.
var licenses = CurrentApp.LicenseInformation.ProductLicenses;
if (licenses.Count == 0)
{
Logger.Debug("Licenses for MS server is zero.");
return;
}
else
{
string str = string.Empty;
foreach (var item in licenses)
{
str = str + item.Value.ProductId + " ";
}
Logger.Debug("PURCHSE_STORE First call to sync. Product ids found :" + str);
}
I have published app on Windows Phone Store (in hidden mode) and created In App Product PRODUCT_1 with price zero. I have downloaded app on my two test devices DEVICE A and DEVICE B which are configured with same account. Now I made an In App Purchase on DEVICE A for PRODUCT_1 . After some time when I launched app on DEVICE A and DEVICE B, I expect to see PRODUCT_1 in log of both devices. But its only appearing in log of DEVICE A on which I made purchase not on DEVICE B.
Products are 'Consumable' because we are working on WP 8.0 and we need to create monthly and annual passes. As I understand, in WP 8.0 we can't specify duration of Durables. That's why we are using consumables. We are not fulfilling the product till it expires. For example if user has purchased monthly pass we will give him access for a month then we will send fulfillment request so that he can buy again. Every time user try to access restricted content we check if he has already purchased respective pass.
Please help me in properly restoring in app purchases.

You mention that you haven't fulfilled the product, indicating that you are testing this with 'Consumable' products, not Durables.
The Windows Phone Store does not actually support restoration of Consumables, you're expected to track how many "coins" or "gems" the user has purchased through your own means. See Managing App Updates and Versioning: http://msdn.microsoft.com/library/windows/apps/jj206949(v=vs.105).aspx
If you can use a Durable IAP though everything should work fine and the product will appear under ProductLicenses on other phones w/ the same Microsoft account.

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.

How to find out the availability status of a Web API from a Windows Store application

I have a Line-of-Business (LoB) Windows 8.1 Store application I developed for a client. The client side-loads it on several Windows 10 tablets. They use it in an environment where WiFi is spotty at best and they would like to get some sort of notification inside the app, regardless of what page they are on, notification that will let them know that they've lost connectivity to the network. I have created a method on my Web API that is not hitting the repository (database). Instead, it quickly returns some static information regarding my Web API, such as version, date and time of the invocation and some trademark stuff that I'm required to return. I thought of calling this method at precise intervals of time and when there's no response, assume that the Web API connectivity is lost. In my main page, the first one displayed when the application is started, I have the following stuff in the constructor of my view model:
_webApiStatusTimer = new DispatcherTimer();
_webApiStatusTimer.Tick += OnCheckWebApiStatusEvent;
_webApiStatusTimer.Interval = new TimeSpan(0, 0, 30);
_webApiStatusTimer.Start();
Then, the event handler is implemented like this:
private async void OnCheckWebApiStatusEvent(object sender, object e)
{
// stop the timer
_webApiStatusTimer.Stop();
// refresh the search
var webApiInfo = await _webApiClient.GetWebApiInfo();
// add all returned records in the list
if (webApiInfo == null)
{
var messageDialog = new MessageDialog(#"The application has lost connection with the back-end Web API!");
await messageDialog.ShowAsync();
// restart the timer
_webApiStatusTimer.Start();
}
}
When the Web API connection is lost, I get a nice popup message that informs me that the Web API is no longer available. The problem I have is that after a while, especially if I navigate away from the first page but not necessary, I get an UnauthorizedAccessException in my application.
I use the DispatcherTimer since my understanding is that this is compatible with
UI threads, but obviously, I still do something wrong. Anyone cares to set me on the right path?
Also, if you did something similar and found a much better approach, I'd love to hear about your solution.
Thanks in advance,
Eddie
First, If you are using Windows Store Apps, then you could possibly use a Background task to check poll for the status of the web api instead of putting this responsibility on your view model, its not the viewmodels concern
Second, if you are connecting from your Windows store app to your API then one successful authentication/ authorization for the first time, how and where do you store the token (assuming you are using token authentication). If you are (and ideally you should), is there a timer that you start which is set to the token expiration time? Is your local storage getting flushed somehow and loosing the aurthorization data?
Need more information.

how to get my device token in nokia lumia 630

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.

In app purchase consumable product responding error

I am developing application with In app feature and need to purchase again and again according to need of user, but the application gets crash when we try to purchase product again with fallowing error message--The original purchase must be reported as fulfilled before you can try to repurchase
I tried using ReportProductFulfillment(pID); but not sure about the position to use this method,
please suggest me what to do?
Note-my product is consumable
Thanks.
Had you used this method?Please try this When receipt came from server(Windows Store).
ReportProductFulfillment(productId);
// Summary:
// Notifies the marketplace that the application has delivered the paid-for
// goods to the user. You cannot repurchase a product until you have confirmed
// its delivery using this method
//
// Parameters:
// productId:
// The ID of the product that has been delivered to the user.
public static void ReportProductFulfillment(string productId);

Saving data on a device, and send the data to a base when the device gets an Internet signal

I am currently in a team developing an app for the platform iOS. All the scores in this game are sent to a mysql base and displayed on a webpage. Sending this data to the mysql base requires Internet of course.
My question is, are there anyone where who know how to save this score locally on the phone or tablet, and make it send the score automatically to the mysql base when the device gets an internet signal?
Code used to send data from the device to the database:
-(void) startNewGame:(ccTime) delta {
NSString *strURL = [NSString stringWithFormat:#"http://erlpil.com/stumpp/settscore.php?poeng=%i", score];
Yes, you can use a class provided by Apple called Reachability to verify the internet connection status, and NSNotificationCenter to keep waiting for any internet connection status. Thus, you could send the scores to your mysql database using the methods described above by #trojanfoe.
To verify internet status first check if any host is reachable, if it is, we understand that there is an internet connection:
- (BOOL)verifyInternetStatus
{
Reachability *reachable = [Reachability reachabilityWithHostName:#"www.google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
if (internetStatus == NotReachable) {
// there's not internet connection, therefore we save the scores locally
}
else {
// send the scores to the database
}
}
When the internet status changes, Reachability class notifies to its observers through NSNotificationCenter that internet status has changed using the key kReachabilityChangedNotification. So, you need to add your class as an observer of this key:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(verifyInternetStatus:)
name:kReachabilityChangedNotification
object:nil];
This is one way to doing so. When you want to send the score, call the method verifyInternetStatus it will send the score or will save it locally.
I hope it helps.
EDIT:
Sorry, i've forgot the class:
https://developer.apple.com/iphone/library/samplecode/Reachability/index.html