Determine location using Microsoft Location Service API in Windowsphone7 - windows-phone-7

I submit my app on windows-phone7 store, Microsoft need following requirement to certify the app.
The following requirements apply to applications that receive the location of a user's mobile device:
2.7.1 Your application must determine location using Microsoft Location Service API.
2.7.2 The privacy policy of your application must inform users about how location data from the Location Service API is used and disclosed and the controls that users have over the use and sharing
of location data. This can be hosted within or directly linked from the application.
Please help me what i want to mentioned or implement to certify the app.

Here is the code I use to get the location.
private static GeoCoordinateWatcher Watcher;
private void StartGeoWatcher()
{
if (Watcher == null)
{
Watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
Watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged);
Watcher.TryStart(false, System.TimeSpan.FromMilliseconds(1000));
}
}
private void OnPositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
latitude = e.Position.Location.Latitude;
longitude = e.Position.Location.Longitude;
}

Related

Integrating Facebook Audience Network in Xamarin

I have been trying to integrate Facebook Audience Network so as to load native ads in my Xamarin Native iOS application. When I debug my application the code enters method "NativeAdDidFail" and the NSError says "No fill" and No other information is printed in the console.
This is what I have done:
Created a resource in business manager and Selected iOS as the target platform.
I left out the payment/mediation and app store URL since my app is not published.
Added an ad placement for native ads and Added one test device in the Monetization manager by adding my iphones IDFA.
Enabled testing, Checked the checkbox for "use real ads", I also clicked on the "choose ad type" but it doesnt seem to be saved?
Added one test user in business manager and Assigned access to the created property.
Downloaded native Facebook app and Enabled tracking in the background for the native facebook app.
Logged in on the native app with the email of the test user that I added.
Added "SkadNetworkIdentifier" and LSApplicationQueriesSchemes in info.plist-> v9wttpbfk9.skadnetwork & n38lu8286q.skadnetwork
Downloaded Xamarin.Facebook.Audiencenetwork.ios
This is my code:
AdSettings.SetAdvertiserTrackingEnabled(false);
AdSettings.ClearTestDevices();
AdSettings.AddTestDevice("74312C38-4958-4187-B385-9FCFE68FRRA9");
nativeAd = new NativeAd("CAROUSEL_IMG_SQUARE_LINK#611875720420055_511995483752412")
{ Delegate = this };
nativeAd.LoadAd();
[Export("nativeAdDidLoad:")]
public void NativeAdDidLoad(NativeAd nativeAd)
{
}
[Export("nativeAd:didFailWithError:")]
public void NativeAdDidFail(NativeAd nativeAd, NSError error)
{
var errorcode = error.Code;
Console.WriteLine($"{nameof(NativeAdDidFail)} - Native ad failed to load with error: {error.LocalizedDescription}");
//AppDelegate.ShowMessage("Native Ad Error", error.LocalizedDescription, NavigationController);
}
[Export("nativeAdDidClick:")]
public void NativeAdDidClick(NativeAd nativeAd) =>
Console.WriteLine($"{nameof(NativeAdDidClick)} - Native ad was clicked.");
[Export("nativeAdDidFinishHandlingClick:")]
public void NativeAdDidFinishHandlingClick(NativeAd nativeAd) =>
Console.WriteLine($"{nameof(NativeAdDidFinishHandlingClick)} - Native ad did finish click handling.");
[Export("nativeAdWillLogImpression:")]
public void NativeAdWillLogImpression(NativeAd nativeAd) =>
Console.WriteLine($"{nameof(NativeAdWillLogImpression)} - Native ad impression is being captured.");
Here's the tutorial I am trying to follow
According to the Facebook Audience Network, this could be the possible reasons:

How can I create a WCF Service Application in Visual Studio that does NOT use a Web Server

I have a simple task: A program (executable) is supposed to call a function of another program (also executable) with some parameters. Program A is supposed to be started, call the function and then terminate. Program B is legacy program that has a GUI and runs continuously. Both programs run on the same Windows PC and use the .NET Framework. I have no experience in web development and Program B is not supposed to run as a web service! Named pipes seem like a good option.
I researched what the best method would be and wanted to try WCF. The documentation claims that "A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application". From that I understand that I can run Program B as a service without hosting a web server.
However everything I see in Visual Studio seems to presume I want to run a server. Wenn I want to create a new WCF project in Visual Studio the only options are a library or "A project for creating WCF service application that is hosted in IIS/WAS". Once I've created said project the debugger wants me to choose a browser for hosting the service.
In another StackOverflow topic a popular suggestion was using this website as a guide and simply removing the http references since the guide is for both named pipes and http. Another indication that it should be possible.
So can someone point me in the right direction? What am I missing? How can I use WCF with nothing related to Web Development involved?
You have already been on the way, it is enough to host the web service in Program B, without specifying a web server. this is called a self-hosted WCF. As the link you provided mentioned, the Service host class is used to host the WCF service, which means that we can host the service in the Console/Winform, and so on.
Here is an example of hosting the service in a Winform application.
public partial class Form1 : Form
{
ServiceHost serviceHost = null;
public Form1()
{
InitializeComponent();
Uri uri = new Uri("http://localhost:9009");
BasicHttpBinding binding = new BasicHttpBinding();
serviceHost = new ServiceHost(typeof(MyService), uri);
serviceHost.AddServiceEndpoint(typeof(IService), binding, "");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior()
{
HttpGetEnabled = true
};
serviceHost.Description.Behaviors.Add(smb);
System.ServiceModel.Channels.Binding mexbinding = MetadataExchangeBindings.CreateMexHttpBinding();
serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexbinding, "mex");
serviceHost.Open();
}
private void Form1_Load(object sender, EventArgs e)
{
if (serviceHost.State==CommunicationState.Opened)
{
this.label1.Text = "Service is running";
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (serviceHost.State==CommunicationState.Opened&&serviceHost.State!=CommunicationState.Closed)
{
serviceHost.Close();
}
}
}
[ServiceContract]
public interface IService
{
[OperationContract]
string Test();
}
public class MyService:IService
{
public string Test()
{
return DateTime.Now.ToLongTimeString();
}
}
After that, we could consume it by using a client proxy.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/accessing-services-using-a-wcf-client
Feel free to let me know if there is anything I can help with.

Getting AppID for Windows Phone in Unity3d

I am developing game for windows phone in unity3d, I have inserted Rate me button in game but on run time in windows phone it didn't work, is there any method to access AppID for the current application running in windows phone developed in Unity3d. I need code in unity3d CSharp for getting AppID.
I tried this C# code in Unity but It didn't work and having error no keywork found windows.
string appId = Windows.ApplicationModel.Store.CurrentApp.AppId.ToString();
LinkUri = new Uri("http://www.windowsphone.com/s?appid=" + appId, UriKind.Absolute)
Here I needed AppID to complete my link for rate me.
As far as i know Unity can not access the Windows namespace but you can make use of EventHandler to call 'Review Task' from Unity. You can do this by following below steps(visit Unity Expert for detailed explanation).
In Unity Game Engine-
Create Event -
using UnityEngine;
using System;
public static class events
{
//Create a new event
public static event EventHandler RateUs;
public static void FireRateUs()
{
Debug.Log ("Opening Rate Task......");
//If event is subscribed than fire it
if(RateUs!=null)
RateUs(null,null);
}
}
Fire Event -
using UnityEngine;
public class RateUs : MonoBehaviour
{
void OnMouseDown()
{
events.FireRateUs();
}
}
In Visual Studio IDE
Subscribe Event -
public MainPage()
{
.
.
.
.
events.RateUs += events_RateUs;
}
Call Function -
void events_RateUs(object sender, EventArgs e)
{
String AppId = Windows.ApplicationModel.Store.CurrentApp.AppId.ToString();
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:reviewapp?appid=" + AppId));
}
You have to get your AppID from your developer's portal on Microsoft Create's web page. You can then hardcode it into your app or save it as a static/globally available variable for accessing purposes. This would mean you would have to begin the process of creating your app entry prior to the programming of the rating game feature. Just create the entry, and don't submit it! Or create it, and add Rate app as an update. I'd choose the former method, personally!
For Apple and Google rating/submit information you have to create the entry ahead of time to get a SKU number. Also in iTunes/Apple/iOS/OSX you have to create the app and give it a unique name, etc in the developer's portal/certificate store.

Windows Phone open another application

I need to open a new application from my application. If it is not installed on the phone then I need to open the installation inside windows store.
Anybody have an idea how can I achieve this?
I read the below articles but I couldn't find anything helpful:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207014%28v=vs.105%29.aspx
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206987%28v=vs.105%29.aspx
Answer:
For the store i ended up using:
private async void test()
{
try
{
Uri uri = new Uri("zune://navigate/?appid=xxx-xxx-xxx-xxx");
await Launcher.LaunchUriAsync(uri);
}
catch (Exception exception)
{
//TODO
}
}
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662937(v=vs.105).aspx
describes how you can launch the store app and display a specific app
What you need will look something like this:
Windows.System.Launcher.LaunchUriAsync(new Uri("zune:navigate?appid=[app ID]"));
where '[app ID]' needs to be replaced by the unique app id of the application you want to install.

Implements a local restaurant search

I am currently trying to have a feature similar to the local scout (search button -> proximity) in my Windows Phone 7 app.
I'd like to get the 10 top restaurants or bars/clubs near my current location. Getting the geolocation of the user is the easy part.
Now I'd like to pass this location to an API and get the results.
I tried Bing Search API but I didn't figure out how to get special locations such as restaurants. And the SOAP service connection wasn't working from my phone.
Then I searched from others API... it seems that Google or Yahoo (PlaceFinder) or maybe Foursquare can be used too. But before investigating further, do you have any ideas of a simply solution to implement the local scout from Bing ?
Or is there another way to implement this feature ?
Oh, and I am french but not specially targeting a market so I'd like to use an international service.
Thanks a lot.
Damien
EDIT :
I guess I found a part of my solution :
Get business type/industry from Bing Phonebook API
As I want to use the Bing Search WSDL, I added a service reference to http://api.search.live.net/soap.asmx?AppId=42 (where 42 is my app key).
When I execute (from my phone) a simple test :
public void Test()
{
BingPortTypeClient bing = new BingPortTypeClient();
SearchRequest request = new SearchRequest();
request.AppId = AppId;
request.Sources = new SourceType[] { SourceType.Web };
request.Query = "restaurant";
bing.SearchCompleted += new EventHandler<SearchCompletedEventArgs>(bing_SearchCompleted);
bing.SearchAsync(request);
}
void bing_SearchCompleted(object sender, SearchCompletedEventArgs e)
{
}
I am getting the following exception :
There was no endpoint listening at http://api.search.live.net/soap.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Inner : The remote server returned an error: NotFound.
I thought using this API would be quite more easy and well-documented...

Resources