My app use phone number as user ID, It will be good to detect the home PLMN of the SIM card and convert it to the country code(like +1, +33, etc.), then you don't have input the digits.
I guess it could be done with RIL in windows mobile, but in a windows phone 7 it seems there is no such kind of APIs.
Another choice is to get the CultureInfo, but some times the CultureInfo may not match with the SIM you are using, for example you take your phone abroad, usually you keep the phone region settings as your home land but you may use a local SIM card.
There does not appear to be any API action that allows you to look at the specific cultures embedded into a SIM for WP7. However, if you the general culture option is still appropriate you could do something like this:
string countryCode = CultureInfo.CurrentCulture.Name;
try {
RegionInfo reg = new RegionInfo(countryCode);
string name = reg.Name;
string displayname = reg.DisplayName;
string ISORegion = reg.TwoLetterISORegionName;
string currency = reg.CurrencySymbol;
string eng = reg.EnglishName;
string native = reg.NativeName;
}
catch (ArgumentException argEx) {
// The country code was not valid
}
If your application needs to be based on the current location please consider using the GPS task. Details for getting GPS data can be reviewed here.
Also converting the GPS data to a specifc country can be completed by geocode reversing as shown here.
Related
I am working with a Trekking website and i have used Zend Framework 2. Any visitor for this site can book Trekking Packages from any country. So my client wants Phone number validation based on country.
So, i have gone through research and till not found a perfect solution. It would be a great help if any one can help me solving this Phone No. validation work.
You will need the intl php extention in order for this to work.
After reading the class PhoneNumber.php under Zend\I18n\Validator. I came up with this.
$post is the form post where the user sends country e.g. GB, the country code e.g. 44, 0044, +44, and the phone number. if i remember correctly the class handles 00 and + but you should confirm.
$phone = new \Zend\I18n\Validator\PhoneNumber();//phone validation
$phone->setCountry($post->country);//set the country (e.g CY)
switch ($post) {
case !$phone->isValid($post->phone_country_code.$post->phone,
array('national'))://check if country and phone are valid
$msg = 'The Phone you Entered is Not valid. Please check the country
code and phone and try again.';
break;
default:
$msg=null;
break; }
In my app i'm having two variables, which i want to retain even after my application is closed.
Which would be the right way to accompolish it?
You can store the values in an IsolatedStorage. There is a very nice article on MSDN regarding the persistance of information on Windows Phone. You can read it here http://msdn.microsoft.com/en-us/library/gg680266(v=pandp.11).aspx
The example shown by Microsoft looks something like this:
private const string CAR_PHOTO_FILE_NAME = "CarPhoto.jpg";
private const string CAR_KEY = "FuelTracker.Car";
private static readonly IsolatedStorageSettings appSettings =
IsolatedStorageSettings.ApplicationSettings;
public static void SaveCar(Action errorCallback)
{
try
{
appSettings[CAR_KEY] = Car;
appSettings.Save();
DeleteTempCarPhoto();
SaveCarPhoto(CAR_PHOTO_FILE_NAME, Car.Picture, errorCallback);
NotifyCarUpdated();
}
catch (IsolatedStorageException)
{
errorCallback();
}
}
The process of reading the information is very much the same. Go through the article and adopt it for your own needs.
There are a number of different storages available on Windows Phone 7.x as well as Windows Phone 8
If these two values of yours are settings, you want to preserve, I recommend you to use the IsolatedStorageSettings. This is a simple key / value store to save and load variables after restart your app. See the the following sample of MSDN (How to create settings)
See a list of other API's and samples on when and how to use it here (Data for Windows Phone on MSDN)
I am using UPS API for address validation. I am very new to this API and have just started learning.
I want to validate an address based on only zipcode i.e. I don't want to suppy the State name. It is not working in Test Integration environment. Any help?
I want to validate address using only Street Address and Zipcode. I don't want to supply State & City name. Is that possible? So far not working.
If I provide both State & Zipcode it is working nice.
How committed are you to the UPS API? My experience is that if they don't have it in the API already, it won't happen soon. There are other APIs available that will let you verify an address based on only the address and the ZIP code. typically, it is not necessary to provide a city or state if you have the correct ZIP code. The minimum required for address validation is street address and zip code or street address and city/state. how many addresses to need to verify each month? If you don't need a whole lot, there are a number of free APIs available. National address server is one, SmartyStreets.com is another. (I work for SmartyStreets.com.)
If you provide blank values for PoliticalDivision1 and PoliticalDivision2 the result back should include the city and state. You must still provide a valid address.
In a C++ application the following XML input used in street level address validator UPS API. Please use appropriate licence number, user id and password.
<?xml version=\"1.0\"?>
<AccessRequest xml:lang=\"en-US\"><AccessLicenseNumber>{LicenceNo}</AccessLicenseNumber><UserId>{UserId}</UserId><Password>{Passwd}</Password></AccessRequest>
<?xml version=\"1.0\"?>
<AddressValidationRequest xml:lang=\"en-US\">
<Request><TransactionReference><CustomerContext>Your Test Case Summary Description</CustomerContext><XpciVersion>1.0</XpciVersion></TransactionReference><RequestAction>XAV</RequestAction><RequestOption>3</RequestOption>
</Request>
<AddressKeyFormat><AddressLine>608 E. Evergreen Rd</AddressLine><PoliticalDivision2>LEBANON</PoliticalDivision2> <PoliticalDivision1>PA</PoliticalDivision1><PostcodePrimaryLow>17042</PostcodePrimaryLow><CountryCode>US</CountryCode> </AddressKeyFormat>
</AddressValidationRequest>
and following output received.
<?xml version=\"1.0\"?>
<AddressValidationResponse>
<Response>
<TransactionReference><CustomerContext>Your Test Case Summary Description</CustomerContext> <XpciVersion>1.0</XpciVersion></TransactionReference> <ResponseStatusCode>1</ResponseStatusCode><ResponseStatusDescription>Success</ResponseStatusDescription>
</Response>
<ValidAddressIndicator/>
<AddressClassification><Code>1</Code><Description>Commercial</Description></AddressClassification>
<AddressKeyFormat><AddressClassification><Code>1</Code><Description>Commercial</Description></AddressClassification><AddressLine>608 E EVERGREEN RD</AddressLine><Region>LEBANON PA 17042-7925</Region><PoliticalDivision2>LEBANON</PoliticalDivision2><PoliticalDivision1>PA</PoliticalDivision1><PostcodePrimaryLow>17042</PostcodePrimaryLow><PostcodeExtendedLow>7925</PostcodeExtendedLow><CountryCode>US</CountryCode></AddressKeyFormat>
</AddressValidationResponse>
Another potential solution besides the UPS API is the Service Objects address validation web service. Full disclosure, I work for Service Objects, but the web service objectively fits your needs.
It can process addresses with just the address1 and zipcode fields. The web service can validate the information, append the city, state, zip+4, note any corrections/changes, and provide a Delivery Point Validation (DPV) code indicating the address's deliverability. Below is an example input and output showing the actual service response.
If you are interested in trying out the API a free trial key is available for testing. You want to get more information about the nitty gritty technical details check out the Developer Guide
Example Input:
Address1: 27 E Cota St Ste 500
Zipcode: 93101
{
"Addresses":[
{
"Address1":"27 E Cota St Ste 500",
"Address2":"",
"City":"Santa Barbara",
"State":"CA",
"Zip":"93101-7602",
"IsResidential":"false",
"DPV":"1",
"DPVDesc":"Yes, the input record is a valid mailing address",
"DPVNotes":"26,28,39",
"DPVNotesDesc":"The input address matched the ZIP+4 record,The input address matched the DPV record,Highrise apartment\/office building address",
"Corrections":"10,23",
"CorrectionsDesc":"City change,State change",
"BarcodeDigits":"931017602254",
"CarrierRoute":"C006",
"CongressCode":"24",
"CountyCode":"083",
"CountyName":"Santa Barbara",
"FragmentHouse":"27",
"FragmentPreDir":"E",
"FragmentStreet":"Cota",
"FragmentSuffix":"St",
"FragmentPostDir":"",
"FragmentUnit":"Ste",
"Fragment":"500",
"FragmentPMBPrefix":"",
"FragmentPMBNumber":""
}
],
"IsCASS":true
}
I am not able to find a way (even with Mango SDK) in which I can show a chooser (say PhoneNumberChooserTask), and get all details about a contact...
Only Name and PhoneNumber is available. For other information like address, I have to use a different chooser. Is there any way in which I can show a chooser (anyone) and get all details...
Phone number
Email address
Photo of the contact
etc.
let me clarify the issue here...
The following code will not work. I want to show a chooser in such a way that it grabs all details. Showing multiple choosers, as I said is not what I want. Imagine asking someone to choose the same contact 3 times to get Email, PhoneNumber and Address.
EmailAddressChooserTask ect = new EmailAddressChooserTask();
ect.Completed += new EventHandler<EmailResult>(ect_Completed);
ect.Show();
PhoneNumberChooserTask pct = new PhoneNumberChooserTask();
pct.Completed += new EventHandler<PhoneNumberResult>(pct_Completed);
pct.Show();
AddressChooserTask act = new AddressChooserTask();
act.Completed += new EventHandler<AddressResult>(act_Completed);
act.Show();
In v7.1 (Mango) you can use the Contacts class. You can use the SearchAsync method providing whatever search criteria you want (DisplayName is the most likely) and then handle the SearchCompleted event and use the ContactsSearchEventArgs.Results to access the returned Contact objects.
From there, you can use the GetPicture method to retrieve the contact image, and the various properties of the Contact object to access all the other information.
Hopefully that will get you started. You can find more information in the Microsoft.Phone.UserData namespace.
I think you can do this with the following tasks:
AddressChooserTask
EmailAddressChooserTask
PhoneNumberChooserTask
How do I find the country code of the phone?
Or perhaps other information about the country that the phone is at?
You can use the CultureInfo.CurrentCulture.Name property:
String currentCultureName = System.Globalization.CultureInfo.CurrentCulture.Name;
will return the culture name that the phone is set to in the format "languagecode-country/regioncode", for example "en-US"
If you're looking for the country of the devices present location you can pull this from the location service and reverse geocoding. An sample implementation here by Nick Harris.
How to Reverse Geocode a Location to an Address on Windows Phone 7
That is what exactly the globalization part in .net is all about. It stores the culture information in a cultureinfo class. currentculture gives the current culture settings.
The most important class in the System.Globalization namespace is the class CultureInfo. CultureInfo represents a culture and defines calendars, formatting of numbers and dates, and sorting strings that are used with the culture. The class RegionInfo represents regional settings(such as the currency) and shows if the region is using the metric system. In the same region, you can use multiple languages. One example is the region of Spain with its Basque(eu-ES), Catalan(ca-ES), Spanish(es-ES), Galician(gl-ES)cultures
eg: CultureInfo ci = new CultureInfo(“fr-FR”);
Refer More in the PPT