Is that possible to make the buy & try options in windows phone 8
like in the windows store apps.
One of my game in the windows store is full access for one week from the day of download. After that windows store itself locks the game(If we give 1 week in the dashboard).
Like that, windows phone 8 having any of the features. .
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286402(v=vs.105).aspx#BKMK_Runningtheapplication
Even i tried for Buy & try using the above link.
I changed the checklicense() like below.
private void CheckLicense()
{
if DEBUG
string message = "This sample demonstrates the implementation of a trial mode in an application." +
"Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.";
if (MessageBox.Show(message, "Debug Trial",
MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
_isTrial = true;
}
else
{
_isTrial = false;
}
else
_isTrial = _licenseInfo.IsTrial();
//Included lines
if(_isTrail)
freeversion = true; //Here Free version trigger when user presses Try
else
freeversion = false; //Here fullversion trigger when user presses Buy
//Included lines
endif
}
If i did like this. I run it in the Master Mode. It always goes for freeversion is false.(i.e: _isTrail is always returns false).
Its because of i have not yet uploaded to windows phone store or some other problem??
Help out to solve this??
There is no automated way to do that on Windows Phone, you'll have to implement the trial limitation yourself in the app.
Note that uninstalling an app on Windows Phone leaves no traces. Therefore, users will be able restart the trial period if they uninstall/reinstall the app.
Here is the code that i used:
private void CheckLicense()
{
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
try
{
var listing = await CurrentApp.LoadListingInformationAsync();
var _price = listing.FormattedPrice;
// start product purchase
await CurrentApp.RequestProductPurchaseAsync("FeatureName", false);
ProductLicense productLicense = null;
if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue("FeatureName", out productLicense))
{
if (productLicense.IsActive)
{
MessageBox.Show("Product purchased");
CurrentApp.ReportProductFulfillment("FeatureName");
ProductPurchased(); // It display product purchased & trigger full version
return;
}
else
{
str = "Purchase failed";
ShowErrorPopup(str); // It shows error msg. purchase failed.
return;
}
}
}
catch (Exception)
{
str = "Purchase failed. Check internet connection and try again";
ShowErrorPopup(str);
return;
}
}
Related
I'm creating a simple program for reading text file on the Windows Phone. I decided to make it a Universal Windows Platform (UWP) App.
In the app, I have a very simple MessageDialog, with three options, Yes, No, Cancel. It works perfectly on the Desktop and in the Simulator. However, when testing with the actual device, the ShowAsync method fails with the message: "Value does not fall in the expected range".
This only happens if there are more than two commands registered in the dialog. Does the MessageDialog class really supports up to three commands - as the documentation suggests - or is this only applying for UWP Apps running on Desktop devices?
At the moment, there is a clear statement in the docs:
The dialog has a command bar that can support up to 3 commands in desktop apps, or 2 commands in mobile apps.
Sad but true: on mobiles, there are two commands only. Need more? Use ContentDialog instead.
It looks like the documentation is missing information about Mobile (and really the API should do a better job here).
For Mobile, if you hit the Back key you get a null return value, so you can do this (not recommended coding pattern, but best I can think of):
async Task Test()
{
const int YES = 1;
const int NO = 2;
const int CANCEL = 3;
var dialog = new MessageDialog("test");
dialog.Commands.Add(new UICommand { Label = "yes", Id = YES });
dialog.Commands.Add(new UICommand { Label = "no", Id = NO });
// Ugly hack; not really how it's supposed to be used.
// TODO: Revisit if MessageDialog API is updated in future release
var deviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily;
if (deviceFamily.Contains("Desktop"))
{
dialog.Commands.Add(new UICommand { Label = "cancel", Id = CANCEL });
}
// Maybe Xbox 'B' button works, but I don't know so best to not do anything
else if (!deviceFamily.Contains("Mobile"))
{
throw new Exception("Don't know how to show dialog for device "
+ deviceFamily);
}
// Will return null if you press Back on Mobile
var result = await dialog.ShowAsync();
// C# 6 syntactic sugar to avoid some null checks
var id = (int)(result?.Id ?? CANCEL);
Debug.WriteLine("You chose {0}", id);
}
The following code displays a proper list of available chromecast devices on my network. But when I click on the links, the application never launches. There are a couple of things that I'm quite confused about that may or may not be related to this question:
If I'm making my own custom application, what's with the DIAL parameters and why do I have to pass them? I don't want to write an app for the DIAL standard... this is MY app.
Again related to the DIAL parameters, if I search for devices with any other query other than "YouTube" (a DIAL parameter), the list always comes up blank. I suppose I shouldn't care, as long as the device is listed... but again... the app won't launch.
It should be noted that my sender app is a chrome webpage.
I'm a bit confused as to where my "appid" goes int he launch parameters,'
<html data-cast-api-enabled="true">
<body>
hi!<BR/>
<script>
var cast_api, cv_activity;
if (window.cast && window.cast.isAvailable) {
// Cast is known to be available
initializeApi();
} else {
// Wait for API to post a message to us
window.addEventListener("message", function(event) {
if (event.source == window && event.data &&
event.data.source == "CastApi" &&
event.data.event == "Hello")
{
//document.write("Initialize via message.<br/>");
initializeApi();
//document.write("Api initialized via message.");
};
});
};
initializeApi = function() {
cast_api = new cast.Api();
cast_api.addReceiverListener("YouTube", onReceiverList);
};
var g_list;
onReceiverList = function(list) {
g_list = list;
// If the list is non-empty, show a widget with
// the friendly names of receivers.
// When a receiver is picked, invoke doLaunch with the receiver.
document.write("Receivers: "+list.length+"<br/>");
var t;
for(t=0;t<list.length;t++)
document.write('found:'+list[t].name+' ' +list[t].id+'<br/>');
};
onLaunch = function(activity) {
if (activity.status == "running") {
cv_activity = activity;
// update UI to reflect that the receiver has received the
// launch command and should start video playback.
} else if (activity.status == "error") {
cv_activity = null;
}
};
function launchy(idx)
{
doLaunch(g_list[idx]);
}
doLaunch = function(receiver) {
var request = new window.cast.LaunchRequest(">>>>>what REALLY goes here?<<<<<<< ", receiver);
request.parameters = "v=abcdefg";
request.description = new window.cast.LaunchDescription();
request.description.text = "My Cat Video";
request.description.url = "http://my.website.get.your.own/chomecast/test.php";
cast_api.launch(request, onLaunch);
};
stopPlayback = function() {
if (cv_activity) {
cast_api.stopActivity(cv_activity.activityId);
}
};
</script>
</body>
</html>
The part marked "what really goes here?" is the part that I THINK is wrong... I couldn't be completely wrong. My device is white listed, I have an appid (which I thought might go in that slot)... The documentation merely says ActivityType DIAL Parmeters are valid, mandatory.
The first argument to the LaunchRequest is your App ID, the one that you have received in an email as part of whitelisting process. Also, the "YouTube" in the initialize method should also be replaced with the same App ID.
I strongly suggest you look at the sample that is on GitHub for chrome sender to see how you can send a request to load a media on a cast device.
Can someone show me or tell some example how to unregister from notification hub in windows phone 8. I tried on this way but it doesn't work.
public void registerForNotifications(string[] tags)
{
var channel = HttpNotificationChannel.Find("xxx");
if (channel == null)
{
channel = new HttpNotificationChannel("xxx");
channel.Open();
channel.BindToShellToast();
}
string[] tagsToSubscribeTo = tags;
channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(async (o, args) =>
{
var hub = new NotificationHub("xxx", "xxx");
await hub.RegisterNativeAsync(args.ChannelUri.ToString(), tagsToSubscribeTo);
});
}
public async void unregisterFromNotifications()
{
var channel = HttpNotificationChannel.Find("xxx");
var hub = new NotificationHub("xxx", "xxx");
await hub.UnregisterAllAsync(channel.ChannelUri.ToString());
}
You didn't say what "it didn't work" means. Did you get an error message? Did it report success but actually fail? In your questions, it really helps more if you share those things. But I'll take a stab at this anyway.
I suspect that you might be using the DefaultListenSharedAccessSignature endpoint from your Windows Phone 8 app.
According to http://msdn.microsoft.com/en-us/library/dn495373.aspx, the Listen access level grants permission to:
Create/Update registration.
Read registration.
Read all registrations for a handle.
Delete registration.
Reading that last one, I wonder if the UnregisterAllAsync method might require a higher access level to delete all registrations, rather than just one.
But rather than use the DefaultFullSharedAccessSignature endpoint, I would rather just try the UnregisterAsync method instead of UnregisterAllAsync.
Disclaimer: I have not tried this out. It may not help at all.
Has anyone else had an issue with the SkyDrive API for Windows Phone 8? I am upgrading my Windows Phone 7 code to Windows Phone 8. When I click on the Login button (SkyDrive) I get the following screen:
This code (unchanged from WP7) used to work in VS2010.
Is anyone else having this issue? Is there a newer version that I should use (current ver. v2.0.50727)?
Current XAML:
HorizontalAlignment="Left" Margin="308,71,0,0"
Name="signInButton1" VerticalAlignment="Top" Width="160"
ClientId="[myID]" Scopes="wl.skydrive_update"
TextType="SignIn" SessionChanged="btnSignin_SessionChanged"
Branding="Windows"/>
Login code-behind:
private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
{
if (e.Status == LiveConnectSessionStatus.Connected)
{
client = new LiveConnectClient(e.Session);
infoTextBlock.Text = "Signed in.";
client.GetCompleted +=
new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
client.GetAsync("me", null);
for (var i = 0; i < this.ApplicationBar.Buttons.Count; i++)
{
var button = this.ApplicationBar.Buttons[i] as ApplicationBarIconButton;
if (button != null)
{
if (button.Text == "Upload")
{
button.IsEnabled = true;
}
}
}
}
else
{
infoTextBlock.Text = "Not signed in.";
client = null;
}
}
UPDATE!
I kept on trying and I was still getting this white screen. However, I clicked on the magnifying glass and then hit the back arrow (it resumed) then tried to login again and it worked. So is this just wonky or what?
After further review, I do believe that this is an emulator issue. If I fiddle with it enough, eventually it works.
I read that one cannot use the LiveSDK in the emulator, because you have no MS account in the emulator.
So try to use a physical device for debugging. That works for me.
How can an extension find out that it is being run for the first time or has just been updated, so that the extension can perform some specific actions? (e.g. open a help page or update settings)
In newer versions of Chrome (since Chrome 22), you can use the chrome.runtime.onInstalled event, which is much cleaner.
Example:
// Check whether new version is installed
chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "install"){
console.log("This is a first install!");
}else if(details.reason == "update"){
var thisVersion = chrome.runtime.getManifest().version;
console.log("Updated from " + details.previousVersion + " to " + thisVersion + "!");
}
});
Updated answer to reflect v3 of manifest:
Chromium now has a chrome.runtime set of APIs, which allow you to fetch the version of the extension.
To get the current version:
chrome.runtime.getManifest().version
To listen when the extension has been first installed, when the extension is updated to a new version, and when Chromium is updated to a new version, you can use the onInstalled event.
chrome.runtime.onInstalled.addListener((details) => {
const currentVersion = chrome.runtime.getManifest().version
const previousVersion = details.previousVersion
const reason = details.reason
console.log(`Previous Version: ${previousVersion }`)
console.log(`Current Version: ${currentVersion }`)
switch (reason) {
case 'install':
console.log('New User installed the extension.')
break;
case 'update':
console.log('User has updated their extension.')
break;
case 'chrome_update':
case 'shared_module_update':
default:
console.log('Other install events within the browser')
break;
}
})
Thats all!
Old answer, prior to 2011
If you want to check if the extension has been installed or updated, you can do something like this:
function onInstall() {
console.log("Extension Installed");
}
function onUpdate() {
console.log("Extension Updated");
}
function getVersion() {
var details = chrome.app.getDetails();
return details.version;
}
// Check if the version has changed.
var currVersion = getVersion();
var prevVersion = localStorage['version']
if (currVersion != prevVersion) {
// Check if we just installed this extension.
if (typeof prevVersion == 'undefined') {
onInstall();
} else {
onUpdate();
}
localStorage['version'] = currVersion;
}
Fortunately, there are now events for this (since Chrome version 22, and 25 for update events).
For an installed event:
chrome.runtime.onInstalled.addListener(function() {...});
For an OnUpdateAvailable event:
chrome.runtime.onUpdateAvailable.addListener(function() {...});
An important excerpt about OnUpdateAvailable from the developer docs says:
Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call chrome.runtime.reload().
Simple. When the extension first runs, the localStorage is empty. On first run, you can write a flag there to mark all consequent runs as non-first.
Example, in background.htm:
var first_run = false;
if (!localStorage['ran_before']) {
first_run = true;
localStorage['ran_before'] = '1';
}
if (first_run) alert('This is the first run!');
EDIT: To check whether the extension has just been updated, store the version instead of a simple flag on first run, then when the current extension version (get it by XmlHttpRequesting the manifest) doesn't equal the one stored in localStorage, the extension has been updated.