Windows Phone 8 In App Purchasing - windows-phone-8

I want in app purchasing in my Windows Phone 8 app. I published my app as beta and also 3 products for this app that u can buy. I copied my ID from Dev Center in Visual Studio 2013. Now I want to test it.
The Problem is when I click on this button:
private async void buttonInfo_Click(object sender, RoutedEventArgs e)
{
StringBuilder sb = new StringBuilder();
var listing = await CurrentApp.LoadListingInformationAsync();
foreach (var product in listing.ProductListings)
{
sb.AppendLine(string.Format("{0}, {1}, {2},{3}, {4}",
product.Key,
product.Value.Name,
product.Value.FormattedPrice,
product.Value.ProductType,
product.Value.Description));
}
MessageBox.Show(sb.ToString(), "List all products", MessageBoxButton.OK);
}
Then the messageBox appears but has no Content. Why not?

You can just debug on it.. make sure
await CurrentApp.LoadListingInformationAsync()
returns the result you expected

It was fixed after a day. no changes in code. xD maybe Servers were not ready

Related

How to collect application logs in windows phone 8.1?

I am new to windows phone platform.Is there anything available like logcat in android for windows for collecting logs?Thanks in advance.
Windows 8.1 introduced new classes to simplify logging. These classes are LoggingChannel, LoggingSession and others.
Here's an example:
App.xaml.cs
LoggingSession logSession;
LoggingChannel logChannel;
public App()
{
this.InitializeComponent();
this.UnhandledException += App_UnhandledException;
}
void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
logChannel.LogMessage("Unhandled exception: " + e.Message);
logSession.SaveToFileAsync(Windows.Storage.ApplicationData.Current.LocalFolder, "MainLog.log").AsTask().Wait();
}
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
logSession = new LoggingSession("MainLogSession");
Resources["MainLogSession"] = logSession;
logChannel = new LoggingChannel("AppLogChannel");
logSession.AddLoggingChannel(logChannel);
}
MainPage.xaml.cs
LoggingChannel logChannel;
public MainPage()
{
this.InitializeComponent();
var logSession = (LoggingSession)Application.Current.Resources["MainLogSession"];
logChannel = new LoggingChannel("MainPageLogChannel");
logSession.AddLoggingChannel(logChannel);
logChannel.LogMessage("MainPage ctor", LoggingLevel.Information);
}
I highly recommend watching the Making your Windows Store Apps More Reliable keynote during the 2013 build conference, where Harry Pierson demonstrates these new APIs in more detail (including uploading the log file to a backend server using a background task that gets executed when the phone is connected to AC power).
You can use System.Diagnostics.Debug to view the logs on Visual Studio Console Window but you won't be able to collect them later because it's only shown during debug.
I recommend the use of MetroLog, a lightweight logging system designed specifically for Windows Store and Windows Phone apps.
You can install it using NuGet
Install-Package MetroLog
Here's an quick example:
using MetroLog;
using MetroLog.Targets;
LogManagerFactory.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new FileStreamingTarget());
GlobalCrashHandler.Configure();
ILogger log = LogManagerFactory.DefaultLogManager.GetLogger<MainPage>();
log.Trace("This is a trace message.");
You can find a tutorial explaining how to add it on your project at http://talkitbr.com/2015/06/11/adicionando-logs-em-universal-apps. Also there is an explanation regarding retrieving these logs.

Application working on emulator but crashed on phone WP8

At start I'm sorry for my English is poor. And this is the only place where i solved the problem.
I have a problem with my application. I write and test it on emulator in VisualStudnio 2012 and It work fine. But when I add aplication in WindowsPhone store and I get to phone. It crashed. I think that problem is in geolocator or something with GPS, because when i use function where my it don't use gps it work. Everywhere where i use geolocator_geopositionchanged it break down and app is terminate. in one of application page i use map control but i gave token and application id but only in class where i use map.
private void maping_Loaded(object sender, RoutedEventArgs e)
{
Microsoft.Phone.Maps.MapsSettings.ApplicationContext.ApplicationId = "id";
Microsoft.Phone.Maps.MapsSettings.ApplicationContext.AuthenticationToken = "token";
}
Do you have any sugestion or advices?
if you want watching app there is a link
http://www.windowsphone.com/pl-PL/store/app/opencaching/06bce1e1-16ef-4ebf-ac53-23b4c725f78b
I have geolocator in a few class it's one of them
Geolocator code
if (!tracking)
{
gps = new Geolocator();
gps.DesiredAccuracy = PositionAccuracy.High;
gps.ReportInterval = 100;
gps.PositionChanged += geolocator_PositionChanged;
}
else
{
gps.PositionChanged -= geolocator_PositionChanged;
gps = null;
}
tracking = !tracking;
Geoposition changed code
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
double distance = 0;
distance = point.GetDistanceTo(new GeoCoordinate(args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude));
string asa = Convert.ToInt64(distance).ToString();
if (asa != null)
{
Dispatcher.BeginInvoke(() =>
{
TBodleglosc.Text = asa +"m";
navi.Rotation = 180 + Kierunek(point.Latitude, point.Longitude, args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude);
});
}
}
Debug on your device. If that cannot repro, setup a Beta Test app and use that to distribute the app back to yourself for debugging. Sometimes signing breaks things.
I debug at lumia 920 and I have a problem with convert.toDouble
because there are was , i have . and vice versa
I think that it's connected with phone language
because in english emulator and Ertay Shashko phone who debug it yesterday it's working fine.
At now application work at phone but doesn't at emulator.
but if i change settings on location and language apps work but I can't debug because visual studio have error
It's weird .....

Push Notification not received by windows phone app : Parse

I have followed all the steps given in the documentation to register for a push notification from the Parse website. (All the steps in the sense I downloaded the default project and added event handler to handle the incoming toast notification).
ParseClient.Initialize("x0uNa3Q164SVGKbH4mxZJaxWxsuYtslB5tVPj893",
"cXFv9RQAoray9xFdwdcZCHXrrkrM6KNd0WyN194H");
this.Startup += async (sender, args) =>
{
// This optional line tracks statistics around app opens, including push effectiveness:
ParseAnalytics.TrackAppOpens(RootFrame);
// By convention, the empty string is considered a "Broadcast" channel
// Note that we had to add "async" to the definition to use the await keyword
await ParsePush.SubscribeAsync("");
};
ParsePush.ToastNotificationReceived += ParsePushOnToastNotificationReceived;
and the handler
private void ParsePushOnToastNotificationReceived(object sender,
NotificationEventArgs notificationEventArgs)
{
var s = new ShellToast();
s.Content = notificationEventArgs.Collection.Values.First();
s.Title = "My Toast";
s.Show();
}
private async void Application_Launching(object sender, LaunchingEventArgs e)
{
await ParseAnalytics.TrackAppOpenedAsync();
}
When I run the app in the emulator it registers the app and I can verify it in my dashboard. But as soon as I send push notification from the website number of registered devices will be shown as 0 and the app doesnt receive the notification.
One thing to mention is this behavior is not consistent. Sometimes the app does receive the notification. Can anyone mention the reason for this or any other point I am missing?
One thing to note is that ShellToast.Show() should only be used from background task. If you call it when an app is in the foreground, toast won't be shown. http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.shelltoast.show(v=vs.105).aspx
So, be sure your app is not in the foreground when you expect to see toast notification.
Firstly you will be shown toast notification only if the foreground app is not running. If your app is running when you receive push notification you have to do like:
void ParsePushOnToastNotificationReceived(object sender,
NotificationEventArgs notificationEventArgs)
{
Deployment.Current.Dispatcher.BeginInvoke(()=>{
// do anything
MessageBox.Show("got notification");
});
}
If your app is not running the os will handle the notification properly, you dont have to do anything.

Windows phone 8 notification hub unregister

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.

Windows Phone WebClient Won't Update New Data

I have a windows phone app that connects to a local IIS Server. It downloads some json data and displays it in a list box. I also have a refresh button on the page. When the page loads everything is correct but pressing the refresh button only returns the same data that was available when the page is loaded. I have checked my web browser with the uri and the updated data shows there correctly. Also If I exit the windows phone app and reload it the data is there. Here is some dumbed down code I am testing with.
On page load:
WebClient download = new WebClient();
download.DownloadStringCompleted += new DownloadStringCompletedEventHandler(download_DownloadStringCompleted);
download.DownloadStringAsync(new Uri("http://sampledata/data"));
void download_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
MessageBox.Show(e.Result);
}
This works fine and displays a message box with my json string.
On Refresh:
private void Button_Click(object sender, RoutedEventArgs e)
{
WebClient refresh = new WebClient();
refresh.DownloadStringCompleted += new DownloadStringCompletedEventHandler(refresh_DownloadStringCompleted);
refresh.DownloadStringAsync(new Uri("http://sampledata/data"));
}
void refresh_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
MessageBox.Show(e.Result);
}
This displays the same json string that was displayed on page load even though the data has changed. Does anyone have any ideas? Thanks.
try adding a time stamp to the end of the URL. like refresh.DownloadStringAsync(new URI("http://sampledata/data" + DateTime.Now.ToString()));
How much data do You pulling out from server? Try with HttpWebRequest if you need heavy lifting. I also had some issuses with webclient loading and refreshing data. Every change on server comes with big delay...