How to get a list of constants from Locale class of Flutter? - flutter

I have an application who use locale to choose the language and a json with translations and I am making a configurator. For it, I need to have a list of locale in the format language_COUNTRYNAME like en_US.
I have found this list of constants in Locale flutter class and I want to get the complete list in JSON without copy it manually, how can I do this ?

I have do finally with the manual way.
Here the list:
{
"af_NA": "Afrikaans Namibia",
"af_ZA": "Afrikaans South Africa",
"agq_CM": "Aghem Cameroon",
"ak_GH": "Akan Ghana",
"am_ET": "Amharic Ethiopia",
"ar_001": "Arabic World",
"ar_AE": "Arabic United Arab Emirates",
"ar_BH": "Arabic Bahrain",
"ar_DJ": "Arabic Djibouti",
"ar_DZ": "Arabic Algeria",
"ar_EG": "Arabic Egypt",
"ar_EH": "Arabic Western Sahara",
"ar_ER": "Arabic Eritrea",
"ar_IL": "Arabic Israel",
"ar_IQ": "Arabic Iraq",
"ar_JO": "Arabic Jordan",
"ar_KM": "Arabic Comoros",
"ar_KW": "Arabic Kuwait",
"ar_LB": "Arabic Lebanon",
"ar_LY": "Arabic Libya",
"ar_MA": "Arabic Morocco",
"ar_MR": "Arabic Mauritania",
"ar_OM": "Arabic Oman",
"ar_PS": "Arabic Palestine",
"ar_QA": "Arabic Qatar",
"ar_SA": "Arabic Saudi Arabia",
"ar_SD": "Arabic Sudan",
"ar_SO": "Arabic Somalia",
"ar_SS": "Arabic South Sudan",
"ar_SY": "Arabic Syria",
"ar_TD": "Arabic Chad",
"ar_TN": "Arabic Tunisia",
"ar_YE": "Arabic Yemen",
"as_IN": "Assamese India",
"asa_TZ": "Asu Tanzania",
"az_AZ": "Azerbaijan",
"bas_CM": "Basaa Cameroon",
"be_BY": "Belarusian Belarus",
"bem_ZM": "Bemba Zambia",
"bez_TZ": "Bena Tanzania",
"bg_BG": "Bulgarian Bulgaria",
"bm_ML": "Bambara Mali",
"bn_BD": "Bengali Bangladesh",
"bn_IN": "Bengali India",
"bo_CN": "Tibetan China",
"bo_IN": "Tibetan India",
"br_FR": "Breton France",
"brx_IN": "Bodo India",
"bs_BA": "Bosnian Bosnia Herzegovina (Cyrillic/Latin)",
"ca_AD": "Catalan Andorra",
"ca_ES": "Catalan Spain",
"ca_FR": "Catalan France",
"ca_IT": "Catalan Italy",
"cgg_UG": "Chiga Uganda",
"chr_US": "Cherokee United States",
"cs_CZ": "Czech Czech Republic",
"cy_GB": "Welsh United Kingdom",
"da_DK": "Danish Denmark",
"da_GL": "Danish Greenland",
"dav_KE": "Taita Kenya",
"de_AT": "German Austria",
"de_BE": "German Belgium",
"de_CH": "German Switzerland",
"de_DE": "German Germany",
"de_LI": "German Liechtenstein",
"de_LU": "German Luxembourg",
"dje_NE": "Zarma Niger",
"dua_CM": "Duala Cameroon",
"dyo_SN": "Jola Fonyi Senegal",
"dz_BT": "Dzongkha Bhutan",
"ebu_KE": "Embu Kenya",
"ee_GH": "Ewe Ghana",
"ee_TG": "Ewe Togo",
"el_CY": "Greek Cyprus",
"el_GR": "Greek Greece",
"en_001": "English World",
"en_150": "English Europe",
"en_AG": "English Antigua Barbuda",
"en_AI": "English Anguilla",
"en_AS": "English American Samoa",
"en_AU": "English Australia",
"en_BB": "English Barbados",
"en_BE": "English Belgium",
"en_BM": "English Bermuda",
"en_BS": "English Bahamas",
"en_BW": "English Botswana",
"en_BZ": "English Belize",
"en_CA": "English Canada",
"en_CC": "English Cocos Keeling Islands",
"en_CK": "English Cook Islands",
"en_CM": "English Cameroon",
"en_CX": "English Christmas Island",
"en_DG": "English Diego Garcia",
"en_DM": "English Dominica",
"en_ER": "English Eritrea",
"en_FJ": "English Fiji",
"en_FK": "English Falkland Islands Islas Malvinas",
"en_FM": "English Micronesia",
"en_GB": "English United Kingdom",
"en_GD": "English Grenada",
"en_GG": "English Guernsey",
"en_GH": "English Ghana",
"en_GI": "English Gibraltar",
"en_GM": "English Gambia",
"en_GU": "English Guam",
"en_GY": "English Guyana",
"en_HK": "English Hong Kong",
"en_IE": "English Ireland",
"en_IM": "English Isle Of Man",
"en_IN": "English India",
"en_IO": "English British Indian Ocean Territory",
"en_JE": "English Jersey",
"en_JM": "English Jamaica",
"en_KE": "English Kenya",
"en_KI": "English Kiribati",
"en_KN": "English Saint Kitts Nevis",
"en_KY": "English Cayman Islands",
"en_LC": "English Saint Lucia",
"en_LR": "English Liberia",
"en_LS": "English Lesotho",
"en_MG": "English Madagascar",
"en_MH": "English Marshall Islands",
"en_MO": "English Macau",
"en_MP": "English Northern Mariana Islands",
"en_MS": "English Montserrat",
"en_MT": "English Malta",
"en_MU": "English Mauritius",
"en_MW": "English Malawi",
"en_NA": "English Namibia",
"en_NF": "English Norfolk Island",
"en_NG": "English Nigeria",
"en_NR": "English Nauru",
"en_NU": "English Niue",
"en_NZ": "English New Zealand",
"en_PG": "English Papua New Guinea",
"en_PH": "English Philippines",
"en_PK": "English Pakistan",
"en_PN": "English Pitcairn Islands",
"en_PR": "English Puerto Rico",
"en_PW": "English Palau",
"en_RW": "English Rwanda",
"en_SB": "English Solomon Islands",
"en_SC": "English Seychelles",
"en_SD": "English Sudan",
"en_SG": "English Singapore",
"en_SH": "English Saint Helena",
"en_SL": "English Sierra Leone",
"en_SS": "English South Sudan",
"en_SX": "English Sint Maarten",
"en_SZ": "English Swaziland",
"en_TC": "English Turks Caicos Islands",
"en_TK": "English Tokelau",
"en_TO": "English Tonga",
"en_TT": "English Trinidad Tobago",
"en_TV": "English Tuvalu",
"en_TZ": "English Tanzania",
"en_UG": "English Uganda",
"en_UM": "English Us Outlying Islands",
"en_US": "English United States",
"en_VC": "English St Vincent Grenadines",
"en_VG": "English British Virgin Islands",
"en_VI": "English Us Virgin Islands",
"en_VU": "English Vanuatu",
"en_WS": "English Samoa",
"en_ZA": "English South Africa",
"en_ZM": "English Zambia",
"en_ZW": "English Zimbabwe",
"es_419": "Spanish Latin America",
"es_AR": "Spanish Argentina",
"es_BO": "Spanish Bolivia",
"es_CL": "Spanish Chile",
"es_CO": "Spanish Colombia",
"es_CR": "Spanish Costa Rica",
"es_CU": "Spanish Cuba",
"es_DO": "Spanish Dominican Republic",
"es_EA": "Spanish Ceuta Melilla",
"es_EC": "Spanish Ecuador",
"es_ES": "Spanish Spain",
"es_GQ": "Spanish Equatorial Guinea",
"es_GT": "Spanish Guatemala",
"es_HN": "Spanish Honduras",
"es_IC": "Spanish Canary Islands",
"es_MX": "Spanish Mexico",
"es_NI": "Spanish Nicaragua",
"es_PA": "Spanish Panama",
"es_PE": "Spanish Peru",
"es_PH": "Spanish Philippines",
"es_PR": "Spanish Puerto Rico",
"es_PY": "Spanish Paraguay",
"es_SV": "Spanish El Salvador",
"es_US": "Spanish United States",
"es_UY": "Spanish Uruguay",
"es_VE": "Spanish Venezuela",
"et_EE": "Estonian Estonia",
"eu_ES": "Basque Spain",
"ewo_CM": "Ewondo Cameroon",
"fa_AF": "Persian Afghanistan",
"fa_IR": "Persian Iran",
"ff_SN": "Fulah Senegal",
"fi_FI": "Finnish Finland",
"fil_PH": "Filipino Philippines",
"fo_FO": "Faroese Faroe Islands",
"fr_BE": "French Belgium",
"fr_BF": "French Burkina Faso",
"fr_BI": "French Burundi",
"fr_BJ": "French Benin",
"fr_BL": "French Saint Bartelemy",
"fr_CA": "French Canada",
"fr_CD": "French Congo Drc",
"fr_CF": "French Central African Republic",
"fr_CG": "French Congo Republic",
"fr_CH": "French Switzerland",
"fr_CI": "French Cote D Ivoire",
"fr_CM": "French Cameroon",
"fr_DJ": "French Djibouti",
"fr_DZ": "French Algeria",
"fr_FR": "French France",
"fr_GA": "French Gabon",
"fr_GF": "French French Guiana",
"fr_GN": "French Guinea",
"fr_GP": "French Guadeloupe",
"fr_GQ": "French Equatorial Guinea",
"fr_HT": "French Haiti",
"fr_KM": "French Comoros",
"fr_LU": "French Luxembourg",
"fr_MA": "French Morocco",
"fr_MC": "French Monaco",
"fr_MF": "French Saint Martin",
"fr_MG": "French Madagascar",
"fr_ML": "French Mali",
"fr_MQ": "French Martinique",
"fr_MR": "French Mauritania",
"fr_MU": "French Mauritius",
"fr_NC": "French New Caledonia",
"fr_NE": "French Niger",
"fr_PF": "French French Polynesia",
"fr_PM": "French Saint Pierre Miquelon",
"fr_RE": "French Reunion",
"fr_RW": "French Rwanda",
"fr_SC": "French Seychelles",
"fr_SN": "French Senegal",
"fr_SY": "French Syria",
"fr_TD": "French Chad",
"fr_TG": "French Togo",
"fr_TN": "French Tunisia",
"fr_VU": "French Vanuatu",
"fr_WF": "French Wallis Futuna",
"fr_YT": "French Mayotte",
"ga_IE": "Irish Ireland",
"gl_ES": "Galician Spain",
"gsw_CH": "Swiss German Switzerland",
"gsw_LI": "Swiss German Liechtenstein",
"gu_IN": "Gujarati India",
"guz_KE": "Gusii Kenya",
"gv_IM": "Manx Isle Of Man",
"ha_GH": "Hausa Latin Ghana",
"ha_NE": "Hausa Latin Niger",
"ha_NG": "Hausa Latin Nigeria",
"haw_US": "Hawaiian United States",
"hi_IN": "Hindi India",
"hr_BA": "Croatian Bosnia Herzegovina",
"hr_HR": "Croatian Croatia",
"hu_HU": "Hungarian Hungary",
"hy_AM": "Armenian Armenia",
"ig_NG": "Igbo Nigeria",
"ii_CN": "Sichuan Yi China",
"in_ID": "Indonesian Indonesia",
"is_IS": "Icelandic Iceland",
"it_CH": "Italian Switzerland",
"it_IT": "Italian Italy",
"it_SM": "Italian San Marino",
"iw_IL": "Hebrew Israel",
"ja_JP": "Japanese Japan",
"jgo_CM": "Ngomba Cameroon",
"jmc_TZ": "Machame Tanzania",
"ka_GE": "Georgian Georgia",
"kab_DZ": "Kabyle Algeria",
"kam_KE": "Kamba Kenya",
"kde_TZ": "Makonde Tanzania",
"kea_CV": "Kabuverdianu Cape Verde",
"khq_ML": "Koyra Chiini Mali",
"ki_KE": "Kikuyu Kenya",
"kk_KZ": "Kazakh Cyrillic Kazakhstan",
"kkj_CM": "Kako Cameroon",
"kl_GL": "Kalaallisut Greenland",
"kln_KE": "Kalenjin Kenya",
"km_KH": "Khmer Cambodia",
"kn_IN": "Kannada India",
"ko_KP": "Korean North Korea",
"ko_KR": "Korean South Korea",
"kok_IN": "Konkani India",
"ks_IN": "Kashmiri Arabic India",
"ksb_TZ": "Shambala Tanzania",
"ksf_CM": "Bafia Cameroon",
"kw_GB": "Cornish United Kingdom",
"ky_KG": "Kyrgyz Cyrillic Kyrgyzstan",
"lag_TZ": "Langi Tanzania",
"lg_UG": "Ganda Uganda",
"lkt_US": "Lakota United States",
"ln_AO": "Lingala Angola",
"ln_CD": "Lingala Congo Drc",
"ln_CF": "Lingala Central African Republic",
"ln_CG": "Lingala Congo Republic",
"lo_LA": "Lao Laos",
"lt_LT": "Lithuanian Lithuania",
"lu_CD": "Luba Katanga Congo Drc",
"luo_KE": "Luo Kenya",
"luy_KE": "Luyia Kenya",
"lv_LV": "Latvian Latvia",
"mas_KE": "Masai Kenya",
"mas_TZ": "Masai Tanzania",
"mer_KE": "Meru Kenya",
"mfe_MU": "Morisyen Mauritius",
"mg_MG": "Malagasy Madagascar",
"mgh_MZ": "Makhuwa Meetto Mozambique",
"mgo_CM": "Meta Cameroon",
"mk_MK": "Macedonian Macedonia Fyrom",
"ml_IN": "Malayalam India",
"mn_MN": "Mongolian Cyrillic Mongolia",
"mr_IN": "Marathi India",
"ms_BN": "Malay Latin Brunei",
"ms_MY": "Malay Latin Malaysia",
"ms_SG": "Malay Latin Singapore",
"mt_MT": "Maltese Malta",
"mua_CM": "Mundang Cameroon",
"my_MM": "Burmese Myanmar Burma",
"naq_NA": "Nama Namibia",
"nb_NO": "Norwegian Bokmal Norway",
"nb_SJ": "Norwegian Bokmal Svalbard Jan Mayen",
"nd_ZW": "North Ndebele Zimbabwe",
"ne_IN": "Nepali India",
"ne_NP": "Nepali Nepal",
"nl_AW": "Dutch Aruba",
"nl_BE": "Dutch Belgium",
"nl_BQ": "Dutch Caribbean Netherlands",
"nl_CW": "Dutch Curacao",
"nl_NL": "Dutch Netherlands",
"nl_SR": "Dutch Suriname",
"nl_SX": "Dutch Sint Maarten",
"nmg_CM": "Kwasio Cameroon",
"nn_NO": "Norwegian Nynorsk Norway",
"nnh_CM": "Ngiemboon Cameroon",
"nus_SD": "Nuer Sudan",
"nyn_UG": "Nyankole Uganda",
"om_ET": "Oromo Ethiopia",
"om_KE": "Oromo Kenya",
"or_IN": "Oriya India",
"pa_IN": "Punjabi Gurmukhi India",
"pa_PK": "Punjabi Arabic Pakistan",
"pl_PL": "Polish Poland",
"ps_AF": "Pashto Afghanistan",
"pt_AO": "Portuguese Angola",
"pt_BR": "Portuguese Brazil",
"pt_CV": "Portuguese Cape Verde",
"pt_GW": "Portuguese Guinea Bissau",
"pt_MO": "Portuguese Macau",
"pt_MZ": "Portuguese Mozambique",
"pt_PT": "Portuguese Portugal",
"pt_ST": "Portuguese Sao Tome Principe",
"pt_TL": "Portuguese Timor Leste",
"rm_CH": "Romansh Switzerland",
"rn_BI": "Rundi Burundi",
"ro_MD": "Romanian Moldova",
"ro_RO": "Romanian Romania",
"rof_TZ": "Rombo Tanzania",
"ru_BY": "Russian Belarus",
"ru_KG": "Russian Kyrgyzstan",
"ru_KZ": "Russian Kazakhstan",
"ru_MD": "Russian Moldova",
"ru_RU": "Russian Russia",
"ru_UA": "Russian Ukraine",
"rw_RW": "Kinyarwanda Rwanda",
"rwk_TZ": "Rwa Tanzania",
"saq_KE": "Samburu Kenya",
"sbp_TZ": "Sangu Tanzania",
"seh_MZ": "Sena Mozambique",
"ses_ML": "Koyraboro Senni Mali",
"sg_CF": "Sango Central African Republic",
"shi_MA": "Tachelhit Morocco (Tifinagh/Latin)",
"si_LK": "Sinhala Sri Lanka",
"sk_SK": "Slovak Slovakia",
"sl_SI": "Slovenian Slovenia",
"sn_ZW": "Shona Zimbabwe",
"so_DJ": "Somali Djibouti",
"so_ET": "Somali Ethiopia",
"so_KE": "Somali Kenya",
"so_SO": "Somali Somalia",
"sq_AL": "Albanian Albania",
"sq_MK": "Albanian Macedonia Fyrom",
"sq_XK": "Albanian Kosovo",
"sr_BA": "Serbian Bosnia Herzegovina (Cyrillic/Latin)",
"sr_ME": "Serbian Montenegro (Cyrillic/Latin)",
"sr_RS": "Serbian Serbia (Cyrillic/Latin)",
"sr_XK": "Serbian Kosovo (Cyrillic/Latin)",
"sv_AX": "Swedish Aland Islands",
"sv_FI": "Swedish Finland",
"sv_SE": "Swedish Sweden",
"sw_KE": "Swahili Kenya",
"sw_TZ": "Swahili Tanzania",
"sw_UG": "Swahili Uganda",
"swc_CD": "Congo Swahili Congo Drc",
"ta_IN": "Tamil India",
"ta_LK": "Tamil Sri Lanka",
"ta_MY": "Tamil Malaysia",
"ta_SG": "Tamil Singapore",
"te_IN": "Telugu India",
"teo_KE": "Teso Kenya",
"teo_UG": "Teso Uganda",
"th_TH": "Thai Thailand",
"ti_ER": "Tigrinya Eritrea",
"ti_ET": "Tigrinya Ethiopia",
"to_TO": "Tongan Tonga",
"tr_CY": "Turkish Cyprus",
"tr_TR": "Turkish Turkey",
"twq_NE": "Tasawaq Niger",
"tzm_MA": "Central Atlas Tamazight Latin Morocco",
"ug_CN": "Uyghur Arabic China",
"uk_UA": "Ukrainian Ukraine",
"ur_IN": "Urdu India",
"ur_PK": "Urdu Pakistan",
"uz_AF": "Uzbek Arabic Afghanistan",
"uz_UZ": "Uzbek Uzbekistan (Cyrillic/Latin)",
"vai_LR": "Vai Latin Liberia (Vai/Latin)",
"vi_VN": "Vietnamese Vietnam",
"vun_TZ": "Vunjo Tanzania",
"xog_UG": "Soga Uganda",
"yav_CM": "Yangben Cameroon",
"yo_BJ": "Yoruba Benin",
"yo_NG": "Yoruba Nigeria",
"zgh_MA": "Standard Moroccan Tamazight Morocco",
"zh_CN": "Chinese Simplified Han China",
"zh_HK": "Chinese Han Hong Kong (Simplified+Traditional)",
"zh_MO": "Chinese Han Macau (Simplified+Traditional)",
"zh_SG": "Chinese Simplified Han Singapore",
"zh_TW": "Chinese Traditional Han Taiwan",
"zu_ZA": "Zulu South Africa"
}

Related

how to create complex json using json_model pakage flutter

"masses": [
{
"Sunday":
[
{
"mass_timing": "7.00 AM",
"mass_place": "First Mass",
"mass_note": "English Mass"
},
{
"mass_timing": "7.00 AM",
"mass_place": "First Mass",
"mass_note": "English Mass"
}
]
},
{
"Monday": [
{
"mass_timing": "7.00 AM",
"mass_place": "First Mass",
"mass_note": "English Mass"
},
{
"mass_timing": "7.00 AM",
"mass_place": "First Mass",
"mass_note": "English Mass"
}
]
} ]
My JSON is like this I need to create a JSON model using the package json_model
can anyone help me to create the json_model dynamic json file to generate json serialization
I will suggest using https://app.quicktype.io/ as it's as it's name says, very quick and you don't need to add a package in your project but of course you need some little modifications on your model to customize it on your case, just choose dart and enjoy.

How to use count and where function in MongoDB?

Need some help here..have been stuck for awhile.
List all Name, Company Name of clients who have applied more than 2 loans which has a yearly repayment plan.
I should get 3 outputs:
John Tan, Happy Food Industry Pte Ltd
Mary Lee, Nice Man Advertising Pte Ltd
Yuyu Lee, NAGM Tuition Centre
My dataset:
[
{
"name": "John Tan",
"contact_number": [
"81726351",
"92019283",
"90192837"
],
"company_name": "Happy Food Industry Pte Ltd",
"company_registration_number": 950001819,
"type_of_ownership": "owner",
"last_roll_call": "16-06-21",
"follow_up_notes": "Do not require any loan at this moment",
"need_to_follow_up": "Yes",
"plan_next_call": "01-12-21",
"financial_year_ended": "30-06-21",
"profit_and_lost_as_on_last_closing": 8000,
"cumulative_profit_and_lost_as_on_last_closing": 50000,
"loan_applied": [
"Purchase of delivery lorry",
"Renovation of tuition centre"
],
"commission_date": "01-12-19",
"loan_duration_in_mths": 24,
"interest_rate": 3,
"repayment_plan": "yearly",
"loan_amount": 138058298,
"status": "Requesting for delay payments",
"other_notes": null
},
{
"name": "Mary Lee",
"contact_number": [
"95213355"
],
"company_name": "Nice Man Advertising Pte Ltd",
"company_registration_number": 960087657,
"type_of_ownership": "Partner with 50% holding",
"last_roll_call": "15-06-21",
"follow_up_notes": "Do not require any loan at this moment",
"need_to_follow_up": "Yes",
"plan_next_call": "Dec 21",
"financial_year_ended": "30-01-21",
"profit_and_lost_as_on_last_closing": 9000,
"cumulative_profit_and_lost_as_on_last_closing": 40000,
"loan_applied": [
"Purchase of crane",
"Purchase of machinery from USA"
],
"commission_date": "01-11-19",
"loan_duration_in_mths": 23,
"interest_rate": 4,
"repayment_plan": "yearly",
"loan_amount": 1237162,
"status": "Healthy",
"other_notes": null
},
{
"name": "Yuyu Lee",
"contact_number": [
"928371623"
],
"company_name": "NAGM Tuition Centre",
"type_of_ownership": "Partner with 20% holding",
"follow_up_notes": "Do not require any loan at this moment",
"need_to_follow_up": "Yes",
"plan_next_call": "12-12-21",
"financial_year_ended": "30-01-21",
"profit_and_lost_as_on_last_closing": 1000000,
"cumulative_profit_and_lost_as_on_last_closing": 3002000,
"loan_applied": [
"Purchase of raw material from China",
"Renovation of shopping mall"
],
"commission_date": "01-11-19",
"loan_duration_in_mths": 11,
"interest_rate": 4,
"repayment_plan": "yearly",
"loan_amount": 918272,
"status": "Completed",
"other_notes": null
},
{
"name": "Joseph Lee",
"contact_number": [
"918273615",
"0192837176",
"1827361923"
],
"company_name": "Akaka Tuition Centre",
"company_registration_number": 929381782,
"type_of_ownership": "Director",
"last_roll_call": "15-11-21",
"follow_up_notes": "Do not require any loan at this moment",
"need_to_follow_up": "No",
"plan_next_call": null,
"financial_year_ended": "30-01-21",
"profit_and_lost_as_on_last_closing": 999999,
"cumulative_profit_and_lost_as_on_last_closing": 9000,
"loan_applied": "Purchase of delivery lorry",
"commission_date": "01-11-19",
"loan_duration_in_mths": 11,
"interest_rate": 4,
"repayment_plan": "monthly",
"loan_amount": 918272,
"status": "Completed",
"other_notes": null
},
{
"name": "Tan Meh Meh",
"contact_number": [
"92837162",
"9189278371"
],
"company_name": "Target Pte Ltd",
"company_registration_number": 293891823,
"type_of_ownership": "Director",
"last_roll_call": "15-12-21",
"follow_up_notes": "Do not require any loan at this moment",
"need_to_follow_up": "Yes",
"plan_next_call": "09-12-21",
"financial_year_ended": "30-01-21",
"profit_and_lost_as_on_last_closing": 12500000,
"cumulative_profit_and_lost_as_on_last_closing": 1500000,
"loan_applied": "Purchase of delivery lorry",
"commission_date": "01-11-19",
"loan_duration_in_mths": 55,
"interest_rate": 4,
"repayment_plan": "monthly",
"loan_amount": 918272,
"status": "Completed",
"other_notes": null
},
{
"name": "Teo Bee Bee",
"contact_number": [
"92039189278",
"192838182",
"192837172"
],
"company_name": "Hello Kitty Pte Ltd",
"company_registration_number": 102039192,
"type_of_ownership": "Owner",
"last_roll_call": "13-11-21",
"follow_up_notes": "Do not require any loan at this moment",
"need_to_follow_up": "Yes",
"plan_next_call": "09-01-21",
"financial_year_ended": "30-01-21",
"profit_and_lost_as_on_last_closing": 6000,
"cumulative_profit_and_lost_as_on_last_closing": 24000000,
"loan_applied": "Purchase of delivery lorry",
"commission_date": "01-11-19",
"loan_duration_in_mths": 33,
"interest_rate": 4,
"repayment_plan": "monthly",
"loan_amount": 2312333,
"status": "Requesting for delay payments",
"other_notes": null
}
]
The following query will get you what is needed.
db.collection.find( { "loan_applied.1": { "$exists": true }, "repayment_plan": "yearly" } , {"name":1, "company_name": 1} );
Explanation:
Since loan_applied is an array field, we can use the dot notation to see if any element exist after the index 1, which means more than 1 element. We add one more filter for repayment_plan.
In the second part of the query, we use projection to return back only name and company_name.

Outlook MAPI Message Class Metadata in Outlook 2016

I've been looking all over and I can't seem to find anywhere that MS has this information documented. (This includes the MS documentation on MAPI message classes. This Super User answer elucidates what seems to be all of the standard Message Classes that are possible, but I haven't been able to find a list of the possible metadata that are associated with the Message Classes.
Does anyone know where I can find the metadata for each of the Message Classes as well as a possible brief (or detailed!) description of what the column means? Some of them are pretty obvious ("ReceivedDate", Start, etc.) but others are less obvious.
I've munged around with PowerShell and managed to find the following:
Schedule Meeting Request:
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies ",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"AutoForwarded",
"DeferredDeliveryTime",
"DeleteAfterSubmit",
"ExpiryTime",
"FlagDueBy",
"FlagRequest ",
"FlagStatus",
"OriginatorDeliveryReportRequested",
"ReceivedTime",
"Recipients",
"ReminderSet",
"ReminderTime",
"ReplyRecipients",
"SaveSentMessageFolder",
"SenderName",
"Sent",
"SentOn",
"Submitted",
"Links",
"DownloadState",
"ItemProperties",
"MarkForDownload",
"IsConflict",
"MeetingWorkspaceURL",
"FlagIcon",
"AutoResolvedWinner",
"Conflicts",
"SenderEmailAddress",
"SenderEmailType",
"PropertyAccessor",
"ConversationID",
"SendUsingAccount",
"IsLatestVersion",
"RTFBody",
"RetentionExpirationDate",
"RetentionPolicyName",
"BodyFormat"
RSS:
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"ExpiryTime",
"HTMLBody",
"ReceivedTime",
"SenderName",
"SentOn",
"Links",
"ItemProperties",
"BodyFormat",
"DownloadState",
"InternetCodepage",
"MarkForDownload",
"IsConflict",
"AutoResolvedWinner",
"Conflicts",
"SenderEmailAddress",
"SenderEmailType",
"PropertyAccessor",
"TaskSubject",
"TaskDueDate",
"TaskStartDate",
"TaskCompletedDate",
"ToDoTaskOrdinal",
"ReminderOverrideDefault",
"ReminderPlaySound",
"ReminderSet",
"ReminderSoundFile",
"ReminderTime",
"IsMarkedAsTask",
"ConversationID",
"RTFBody"
Notes:
"Application",
"Class",
"Session",
"Parent",
"Body",
"Categories",
"Color",
"CreationTime",
"EntryID",
"GetInspector",
"Height",
"LastModificationTime",
"Left",
"MessageClass",
"Saved",
"Size",
"Subject",
"Top",
"Width",
"Links",
"DownloadState",
"ItemProperties",
"MarkForDownload",
"IsConflict",
"AutoResolvedWinner",
"Conflicts",
"PropertyAccessor"
Contact:
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"Account",
"Anniversary",
"AssistantName",
"AssistantTelephoneNumber",
"Birthday",
"Business2TelephoneNumber",
"BusinessAddress",
"BusinessAddressCity",
"BusinessAddressCountry",
"BusinessAddressPostalCode",
"BusinessAddressPostOfficeBox",
"BusinessAddressState",
"BusinessAddressStreet",
"BusinessFaxNumber",
"BusinessHomePage",
"BusinessTelephoneNumber",
"CallbackTelephoneNumber",
"CarTelephoneNumber",
"Children",
"CompanyAndFullName",
"CompanyLastFirstNoSpace",
"CompanyLastFirstSpaceOnly",
"CompanyMainTelephoneNumber",
"CompanyName",
"ComputerNetworkName",
"CustomerID",
"Department",
"Email1Address",
"Email1AddressType",
"Email1DisplayName",
"Email1EntryID",
"Email2Address",
"Email2AddressType",
"Email2DisplayName",
"Email2EntryID",
"Email3Address",
"Email3AddressType",
"Email3DisplayName",
"Email3EntryID",
"FileAs",
"FirstName",
"FTPSite",
"FullName",
"FullNameAndCompany",
"Gender",
"GovernmentIDNumber",
"Hobby",
"Home2TelephoneNumber",
"HomeAddress",
"HomeAddressCity",
"HomeAddressCountry",
"HomeAddressPostalCode",
"HomeAddressPostOfficeBox",
"HomeAddressState",
"HomeAddressStreet",
"HomeFaxNumber",
"HomeTelephoneNumber",
"Initials",
"InternetFreeBusyAddress",
"ISDNNumber",
"JobTitle",
"Journal",
"Language",
"LastFirstAndSuffix",
"LastFirstNoSpace",
"LastFirstNoSpaceCompany",
"LastFirstSpaceOnly",
"LastFirstSpaceOnlyCompany",
"LastName",
"LastNameAndFirstName",
"MailingAddress",
"MailingAddressCity",
"MailingAddressCountry",
"MailingAddressPostalCode",
"MailingAddressPostOfficeBox",
"MailingAddressState",
"MailingAddressStreet",
"ManagerName",
"MiddleName",
"MobileTelephoneNumber",
"NetMeetingAlias",
"NetMeetingServer",
"NickName",
"OfficeLocation",
"OrganizationalIDNumber",
"OtherAddress",
"OtherAddressCity",
"OtherAddressCountry",
"OtherAddressPostalCode",
"OtherAddressPostOfficeBox",
"OtherAddressState",
"OtherAddressStreet",
"OtherFaxNumber",
"OtherTelephoneNumber",
"PagerNumber",
"PersonalHomePage",
"PrimaryTelephoneNumber",
"Profession",
"RadioTelephoneNumber",
"ReferredBy",
"SelectedMailingAddress",
"Spouse",
"Suffix",
"TelexNumber",
"Title",
"TTYTDDTelephoneNumber",
"User1",
"User2",
"User3",
"User4",
"UserCertificate",
"WebPage",
"YomiCompanyName",
"YomiFirstName",
"YomiLastName",
"Links",
"ItemProperties",
"LastFirstNoSpaceAndSuffix",
"DownloadState",
"IMAddress",
"MarkForDownload",
"IsConflict",
"AutoResolvedWinner",
"Conflicts",
"HasPicture",
"PropertyAccessor",
"TaskSubject",
"TaskDueDate",
"TaskStartDate",
"TaskCompletedDate",
"ToDoTaskOrdinal",
"ReminderOverrideDefault",
"ReminderPlaySound",
"ReminderSet",
"ReminderSoundFile",
"ReminderTime",
"IsMarkedAsTask",
"BusinessCardLayoutXml",
"BusinessCardType",
"ConversationID",
"RTFBody"
Conversations:
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"AlternateRecipientAllowed",
"AutoForwarded",
"BCC",
"CC",
"DeferredDeliveryTime",
"DeleteAfterSubmit",
"ExpiryTime",
"FlagDueBy",
"FlagRequest",
"FlagStatus",
"HTMLBody",
"OriginatorDeliveryReportRequested",
"ReadReceiptRequested",
"ReceivedByEntryID",
"ReceivedByName",
"ReceivedOnBehalfOfEntryID",
"ReceivedOnBehalfOfName",
"ReceivedTime",
"RecipientReassignmentProhibited",
"Recipients",
"ReminderOverrideDefault",
"ReminderPlaySound",
"ReminderSet",
"ReminderSoundFile",
"ReminderTime",
"RemoteStatus",
"ReplyRecipientNames",
"ReplyRecipients",
"SaveSentMessageFolder",
"SenderName",
"Sent",
"SentOn",
"SentOnBehalfOfName",
"Submitted",
"[To]",
"VotingOptions",
"VotingResponse",
"Links",
"ItemProperties",
"BodyFormat",
"DownloadState",
"InternetCodepage",
"MarkForDownload",
"IsConflict",
"IsIPFax",
"FlagIcon",
"HasCoverSheet",
"AutoResolvedWinner",
"Conflicts",
"SenderEmailAddress",
"SenderEmailType",
"EnableSharedAttachments",
"Permission",
"PermissionService",
"PropertyAccessor",
"SendUsingAccount",
"TaskSubject",
"TaskDueDate",
"TaskStartDate",
"TaskCompletedDate",
"ToDoTaskOrdinal",
"IsMarkedAsTask",
"ConversationID",
"Sender",
"PermissionTemplateGuid",
"RTFBody",
"RetentionPolicyName",
"RetentionExpirationDate"
Tasks:
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"ActualWork",
"CardData",
"Complete",
"Contacts",
"ContactNames",
"DateCompleted",
"DelegationState",
"Delegator",
"DueDate",
"IsRecurring",
"Ordinal",
"Owner",
"Ownership",
"PercentComplete",
"Recipients",
"ReminderTime",
"ReminderOverrideDefault",
"ReminderPlaySound",
"ReminderSet",
"ReminderSoundFile",
"ResponseState",
"Role",
"SchedulePlusPriority",
"StartDate",
"Status",
"StatusOnCompletionRecipients",
"StatusUpdateRecipients",
"TeamTask",
"TotalWork",
"Links",
"DownloadState",
"ItemProperties",
"InternetCodepage",
"MarkForDownload",
"IsConflict",
"AutoResolvedWinner",
"Conflicts",
"PropertyAccessor",
"SendUsingAccount",
"ToDoTaskOrdinal",
"ConversationID",
"RTFBody",
Calendar:
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"AllDayEvent",
"BusyStatus",
"Duration",
"End",
"IsOnlineMeeting",
"IsRecurring",
"Location",
"MeetingStatus",
"NetMeetingAutoStart",
"NetMeetingOrganizerAlias",
"NetMeetingServer",
"NetMeetingType",
"OptionalAttendees",
"Organizer",
"Recipients",
"RecurrenceState",
"ReminderMinutesBeforeStart",
"ReminderOverrideDefault",
"ReminderPlaySound",
"ReminderSet",
"ReminderSoundFile",
"ReplyTime",
"RequiredAttendees",
"Resources",
"ResponseRequested",
"ResponseStatus",
"Start",
"NetMeetingDocPathName",
"NetShowURL",
"Links",
"ConferenceServerAllowExternal",
"ConferenceServerPassword",
"ItemProperties",
"DownloadState",
"InternetCodepage",
"MarkForDownload",
"IsConflict",
"MeetingWorkspaceURL",
"AutoResolvedWinner",
"Conflicts",
"PropertyAccessor",
"SendUsingAccount",
"GlobalAppointmentID",
"ForceUpdateToAllAttendees",
"StartUTC",
"EndUTC",
"StartInStartTimeZone",
"EndInEndTimeZone",
"StartTimeZone",
"EndTimeZone",
"ConversationID",
"RTFBody",
"BodyFormat"
e-mail (IPM.Note):
"Application",
"Class",
"Session",
"Parent",
"Actions",
"Attachments",
"BillingInformation",
"Body",
"Categories",
"Companies",
"ConversationIndex",
"ConversationTopic",
"CreationTime",
"EntryID",
"FormDescription",
"GetInspector",
"Importance",
"LastModificationTime",
"MAPIOBJECT",
"MessageClass",
"Mileage",
"NoAging",
"OutlookInternalVersion",
"OutlookVersion",
"Saved",
"Sensitivity",
"Size",
"Subject",
"UnRead",
"UserProperties",
"AlternateRecipientAllowed",
"AutoForwarded",
"BCC",
"CC",
"DeferredDeliveryTime",
"DeleteAfterSubmit",
"ExpiryTime",
"FlagDueBy",
"FlagRequest",
"FlagStatus",
"HTMLBody",
"OriginatorDeliveryReportRequested",
"ReadReceiptRequested",
"ReceivedByEntryID",
"ReceivedByName",
"ReceivedOnBehalfOfEntryID",
"ReceivedOnBehalfOfName",
"ReceivedTime",
"RecipientReassignmentProhibited",
"Recipients",
"ReminderOverrideDefault",
"ReminderPlaySound",
"ReminderSet",
"ReminderSoundFile",
"ReminderTime",
"RemoteStatus",
"ReplyRecipientNames",
"ReplyRecipients",
"SaveSentMessageFolder",
"SenderName",
"Sent",
"SentOn",
"SentOnBehalfOfName",
"Submitted",
"[To]",
"VotingOptions",
"VotingResponse",
"Links",
"ItemProperties",
"BodyFormat",
"DownloadState",
"InternetCodepage",
"MarkForDownload",
"IsConflict",
"IsIPFax",
"FlagIcon",
"HasCoverSheet",
"AutoResolvedWinner",
"Conflicts",
"SenderEmailAddress",
"SenderEmailType",
"EnableSharedAttachments",
"Permission",
"PermissionService",
"PropertyAccessor",
"SendUsingAccount",
"TaskSubject",
"TaskDueDate",
"TaskStartDate",
"TaskCompletedDate",
"ToDoTaskOrdinal",
"IsMarkedAsTask",
"ConversationID",
"Sender",
"PermissionTemplateGuid",
"RTFBody",
"RetentionPolicyName",
"RetentionExpirationDate"
The Microsoft Outlook object browser displays the classes, properties, methods, and events available from the Outlook object library.
If you do not see the Developer tab, see Run in Developer Mode in Outlook to activate the Developer tab. On the Developer tab, in the Form group, click View Code to open the Script Editor. In the Script Editor, click Object Browser on the Script menu or press F2.
All of the available Outlook objects are listed in the Classes pane of the object browser in alphabetical order. To view the members of an object, select the object in the Classes pane. The members of this object appear in alphabetical order in the Members of pane. The heading at the top of this pane will reflect the name of the object that you select. For example, if you select the AppointmentItem object in the Classes pane, the heading of the Members of pane will appear as Members of AppointmentItem.
The interfaces and members of the Microsoft.Office.Interop.Outlook namespace that provide support for interoperability between the COM object model of Outlook and managed applications that automate Outlook are described here.

How to test the Google Schemas

I am trying to implement the ParcelDelivery feature for my webshop as shown here:
https://developers.google.com/gmail/markup/reference/parcel-delivery
The markup i use validates using this tool:
https://www.google.com/webmasters/markup-tester/
On the help pages it shows that you can test this markup by sending an email from yourself, to yourself. So i am sending myself an email using the GMail web interface, but no matter what i use for the formatting (plain text or html) the "package delivery status" does not show up in my inbox.
Instead, when i click to open the email; the entire code below is shown as the email, just if GMail does not pick it up.
p.s. is this schema also supported in the NOW cards? does anybody know?
Am i doing something wrong?
This is my source used:
<html>
<body>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "ParcelDelivery",
"deliveryAddress": {
"#type": "PostalAddress",
"name": "John Frank",
"streetAddress": "24 Willie Mays Plaza",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"addressCountry": "US",
"postalCode": "94107"
},
"originAddress": {
"#type": "PostalAddress",
"name": "John Frank",
"streetAddress": "25 Willie Mays Plaza",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"addressCountry": "US",
"postalCode": "94107"
},
"expectedArrivalFrom": "2013-03-10T12:00:00-08:00",
"expectedArrivalUntil": "2013-03-12T12:00:00-08:00",
"carrier": {
"#type": "Organization",
"name": "FedEx",
"url": "http://fedex.com/"
},
"itemShipped": {
"#type": "Product",
"name": "iPod Mini",
"url": "http://apple.com/ipad32gb",
"image": "http://apple.com/images/ipad32gb.jpg",
"sku": "B00DR0PDNE",
"description": "iPod Mini 32Gb White",
"brand": {
"#type": "Brand",
"name": "Apple"
},
"color": "white"
},
"trackingNumber": "3453291231",
"trackingUrl": "http://fedex.com/track/3453291231",
"hasDeliveryMethod": "http://schema.org/ParcelService",
"partOfOrder": {
"#type": "Order",
"orderNumber": "176057",
"merchant": {
"#type": "Organization",
"name": "Bob Dole",
"sameAs": "http://www.freebase.com/m/0fhkx"
},
"orderStatus": "http://schema.org/OrderInTransit"
}
}
</script>
<p>
Dear John, thanks for booking your Google I/O ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Reservation number: IO12345<br/>
Order for: John Smith<br/>
Event: Google I/O 2013<br/>
Start time: May 15th 2013 8:00am PST<br/>
Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br/>
</p>
</body>
</html>

How to get the user's country calling code in iOS?

I am developing an iOS app in which the user enters their mobile number. How do I get their country calling code? For example, if a user is in India, then +91 should be prefixed automatically. Is there an option that adds country codes automatically?
Import Statement :
#import<CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
you can get country code for the current Carrier using CoreTelephony framework:
CTTelephonyNetworkInfo *network_Info = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = network_Info.subscriberCellularProvider;
NSLog(#"country code is: %#", carrier.mobileCountryCode);
//will return the actual country code
NSLog(#"ISO country code is: %#", carrier.isoCountryCode);
Apple Docs
with the use of NSLocale you can get the country name, code etc. Take a look at below code it will help you to do so.
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc.
for a countries dialing code you can visit this reference code.
Use this simple function
func getCountryCallingCode(countryRegionCode:String)->String{
let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593", "EG":"20", "ER": "291", "EE":"372","ES": "34", "ET": "251", "FM": "691", "FK": "500", "FO": "298", "FJ": "679", "FI":"358", "FR": "33", "GB":"44", "GF": "594", "GA":"241", "GS": "500", "GM":"220", "GE":"995","GH":"233", "GI": "350", "GQ": "240", "GR": "30", "GG": "44", "GL": "299", "GD":"1", "GP": "590", "GU": "1", "GT": "502", "GN":"224","GW": "245", "GY": "595", "HT": "509", "HR": "385", "HN":"504", "HU": "36", "HK": "852", "IR": "98", "IM": "44", "IL": "972", "IO":"246", "IS": "354", "IN": "91", "ID":"62", "IQ":"964", "IE": "353","IT":"39", "JM":"1", "JP": "81", "JO": "962", "JE":"44", "KP": "850", "KR": "82","KZ":"77", "KE": "254", "KI": "686", "KW": "965", "KG":"996","KN":"1", "LC": "1", "LV": "371", "LB": "961", "LK":"94", "LS": "266", "LR":"231", "LI": "423", "LT": "370", "LU": "352", "LA": "856", "LY":"218", "MO": "853", "MK": "389", "MG":"261", "MW": "265", "MY": "60","MV": "960", "ML":"223", "MT": "356", "MH": "692", "MQ": "596", "MR":"222", "MU": "230", "MX": "52","MC": "377", "MN": "976", "ME": "382", "MP": "1", "MS": "1", "MA":"212", "MM": "95", "MF": "590", "MD":"373", "MZ": "258", "NA":"264", "NR":"674", "NP":"977", "NL": "31","NC": "687", "NZ":"64", "NI": "505", "NE": "227", "NG": "234", "NU":"683", "NF": "672", "NO": "47","OM": "968", "PK": "92", "PM": "508", "PW": "680", "PF": "689", "PA": "507", "PG":"675", "PY": "595", "PE": "51", "PH": "63", "PL":"48", "PN": "872","PT": "351", "PR": "1","PS": "970", "QA": "974", "RO":"40", "RE":"262", "RS": "381", "RU": "7", "RW": "250", "SM": "378", "SA":"966", "SN": "221", "SC": "248", "SL":"232","SG": "65", "SK": "421", "SI": "386", "SB":"677", "SH": "290", "SD": "249", "SR": "597","SZ": "268", "SE":"46", "SV": "503", "ST": "239","SO": "252", "SJ": "47", "SY":"963", "TW": "886", "TZ": "255", "TL": "670", "TD": "235", "TJ": "992", "TH": "66", "TG":"228", "TK": "690", "TO": "676", "TT": "1", "TN":"216","TR": "90", "TM": "993", "TC": "1", "TV":"688", "UG": "256", "UA": "380", "US": "1", "UY": "598","UZ": "998", "VA":"379", "VE":"58", "VN": "84", "VG": "1", "VI": "1","VC":"1", "VU":"678", "WS": "685", "WF": "681", "YE": "967", "YT": "262","ZA": "27" , "ZM": "260", "ZW":"263"]
let countryDialingCode = prefixCodes[countryRegionCode]
return countryDialingCode!
}
And call as
let currentLocale = NSLocale.currentLocale()
let countryCode = currentLocale.objectForKey(NSLocaleCountryCode) as! String//get the set country name, code of your iphone
print("country code is \(countryCode)")
print(getCountryCallingCode(countryCode))
//change country region Settings>>General>>Language&Region>>Region
Swift
let networkInfo = CTTelephonyNetworkInfo()
if let carrier = networkInfo.subscriberCellularProvider {
print("country code is: " + carrier.mobileCountryCode!);
//will return the actual country code
print("ISO country code is: " + carrier.isoCountryCode!);
}
Swift 5
I combine answer from Oded and LC into a function.
func getCountryCode() -> String {
guard let carrier = CTTelephonyNetworkInfo().subscriberCellularProvider, let countryCode = carrier.isoCountryCode else { return "" }
let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593", "EG":"20", "ER": "291", "EE":"372","ES": "34", "ET": "251", "FM": "691", "FK": "500", "FO": "298", "FJ": "679", "FI":"358", "FR": "33", "GB":"44", "GF": "594", "GA":"241", "GS": "500", "GM":"220", "GE":"995","GH":"233", "GI": "350", "GQ": "240", "GR": "30", "GG": "44", "GL": "299", "GD":"1", "GP": "590", "GU": "1", "GT": "502", "GN":"224","GW": "245", "GY": "595", "HT": "509", "HR": "385", "HN":"504", "HU": "36", "HK": "852", "IR": "98", "IM": "44", "IL": "972", "IO":"246", "IS": "354", "IN": "91", "ID":"62", "IQ":"964", "IE": "353","IT":"39", "JM":"1", "JP": "81", "JO": "962", "JE":"44", "KP": "850", "KR": "82","KZ":"77", "KE": "254", "KI": "686", "KW": "965", "KG":"996","KN":"1", "LC": "1", "LV": "371", "LB": "961", "LK":"94", "LS": "266", "LR":"231", "LI": "423", "LT": "370", "LU": "352", "LA": "856", "LY":"218", "MO": "853", "MK": "389", "MG":"261", "MW": "265", "MY": "60","MV": "960", "ML":"223", "MT": "356", "MH": "692", "MQ": "596", "MR":"222", "MU": "230", "MX": "52","MC": "377", "MN": "976", "ME": "382", "MP": "1", "MS": "1", "MA":"212", "MM": "95", "MF": "590", "MD":"373", "MZ": "258", "NA":"264", "NR":"674", "NP":"977", "NL": "31","NC": "687", "NZ":"64", "NI": "505", "NE": "227", "NG": "234", "NU":"683", "NF": "672", "NO": "47","OM": "968", "PK": "92", "PM": "508", "PW": "680", "PF": "689", "PA": "507", "PG":"675", "PY": "595", "PE": "51", "PH": "63", "PL":"48", "PN": "872","PT": "351", "PR": "1","PS": "970", "QA": "974", "RO":"40", "RE":"262", "RS": "381", "RU": "7", "RW": "250", "SM": "378", "SA":"966", "SN": "221", "SC": "248", "SL":"232","SG": "65", "SK": "421", "SI": "386", "SB":"677", "SH": "290", "SD": "249", "SR": "597","SZ": "268", "SE":"46", "SV": "503", "ST": "239","SO": "252", "SJ": "47", "SY":"963", "TW": "886", "TZ": "255", "TL": "670", "TD": "235", "TJ": "992", "TH": "66", "TG":"228", "TK": "690", "TO": "676", "TT": "1", "TN":"216","TR": "90", "TM": "993", "TC": "1", "TV":"688", "UG": "256", "UA": "380", "US": "1", "UY": "598","UZ": "998", "VA":"379", "VE":"58", "VN": "84", "VG": "1", "VI": "1","VC":"1", "VU":"678", "WS": "685", "WF": "681", "YE": "967", "YT": "262","ZA": "27" , "ZM": "260", "ZW":"263"]
let countryDialingCode = prefixCodes[countryCode.uppercased()] ?? ""
return countryDialingCode
}
Make sure to import CoreTelephony at the top
import CoreTelephony
I think you need to use NSLocale for using Country code of the user.
You can follow this link to understand use of NSLocale class reference.
Also study this link for ISOCountryCode property.
Hope this may help you.
I came up with the following code, based on previous answers:
Swift
#if canImport(CoreTelephony)
import CoreTelephony
#endif
static func getRegionCodeFromSim() -> String? {
#if canImport(CoreTelephony)
let networkInfos = CTTelephonyNetworkInfo()
if #available(iOS 12, *) {
let carrier = networkInfos.serviceSubscriberCellularProviders?
.map { $0.1 }
.first { $0.isoCountryCode != nil }
return carrier?.isoCountryCode
}
return networkInfos.subscriberCellularProvider?.isoCountryCode
#else
return nil
#endif
}
static func getRegionCode() -> String? {
guard let regionCodeFromSim = Self.getRegionCodeFromSim() else {
return NSLocale.current.regionCode
}
return regionCodeFromSim
}
static func getCountryCode() -> String? {
guard let regionCode = Self.getRegionCode() else { return nil }
let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593", "EG":"20", "ER": "291", "EE":"372","ES": "34", "ET": "251", "FM": "691", "FK": "500", "FO": "298", "FJ": "679", "FI":"358", "FR": "33", "GB":"44", "GF": "594", "GA":"241", "GS": "500", "GM":"220", "GE":"995","GH":"233", "GI": "350", "GQ": "240", "GR": "30", "GG": "44", "GL": "299", "GD":"1", "GP": "590", "GU": "1", "GT": "502", "GN":"224","GW": "245", "GY": "595", "HT": "509", "HR": "385", "HN":"504", "HU": "36", "HK": "852", "IR": "98", "IM": "44", "IL": "972", "IO":"246", "IS": "354", "IN": "91", "ID":"62", "IQ":"964", "IE": "353","IT":"39", "JM":"1", "JP": "81", "JO": "962", "JE":"44", "KP": "850", "KR": "82","KZ":"77", "KE": "254", "KI": "686", "KW": "965", "KG":"996","KN":"1", "LC": "1", "LV": "371", "LB": "961", "LK":"94", "LS": "266", "LR":"231", "LI": "423", "LT": "370", "LU": "352", "LA": "856", "LY":"218", "MO": "853", "MK": "389", "MG":"261", "MW": "265", "MY": "60","MV": "960", "ML":"223", "MT": "356", "MH": "692", "MQ": "596", "MR":"222", "MU": "230", "MX": "52","MC": "377", "MN": "976", "ME": "382", "MP": "1", "MS": "1", "MA":"212", "MM": "95", "MF": "590", "MD":"373", "MZ": "258", "NA":"264", "NR":"674", "NP":"977", "NL": "31","NC": "687", "NZ":"64", "NI": "505", "NE": "227", "NG": "234", "NU":"683", "NF": "672", "NO": "47","OM": "968", "PK": "92", "PM": "508", "PW": "680", "PF": "689", "PA": "507", "PG":"675", "PY": "595", "PE": "51", "PH": "63", "PL":"48", "PN": "872","PT": "351", "PR": "1","PS": "970", "QA": "974", "RO":"40", "RE":"262", "RS": "381", "RU": "7", "RW": "250", "SM": "378", "SA":"966", "SN": "221", "SC": "248", "SL":"232","SG": "65", "SK": "421", "SI": "386", "SB":"677", "SH": "290", "SD": "249", "SR": "597","SZ": "268", "SE":"46", "SV": "503", "ST": "239","SO": "252", "SJ": "47", "SY":"963", "TW": "886", "TZ": "255", "TL": "670", "TD": "235", "TJ": "992", "TH": "66", "TG":"228", "TK": "690", "TO": "676", "TT": "1", "TN":"216","TR": "90", "TM": "993", "TC": "1", "TV":"688", "UG": "256", "UA": "380", "US": "1", "UY": "598","UZ": "998", "VA":"379", "VE":"58", "VN": "84", "VG": "1", "VI": "1","VC":"1", "VU":"678", "WS": "685", "WF": "681", "YE": "967", "YT": "262","ZA": "27" , "ZM": "260", "ZW":"263"]
return prefixCodes[regionCode.uppercased()]
}
It tries to fetch the country code from the SIM cards (with multi-sim & non-sim devices support), if available, and fallbacks to the device's locale otherwise.
The prefixCodes could be loaded from a PLIST or JSON to help with readability.
If you want to prefixed calling country code automatically
then you need to get user's country code pragmatically and Drag & drop src Folder in your code
Its looks like this:
if let countryCode = (Locale.current as NSLocale).object(forKey: .countryCode) as? String {
print(countryCode)
let strCode = Countries.countryFromCountryCode(countryCode: countryCode)
btnPhoneCode.setTitle("+\(strCode.phoneExtension)", for: .normal)
}
It works for me, Hope will help you too. :)
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
// get country code, e.g. ES (Spain), FR (France), etc.
NSLog(#"country code is:%#",countryCode);
NSString*lower=[countryCode lowercaseString];
NSString *path = [[NSBundle mainBundle] pathForResource:#"DiallingCodes" ofType:#"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSMutableDictionary *_dictCountry=[[NSMutableDictionary alloc]init];
NSMutableArray *_CodeArray=[[NSMutableArray alloc]init];
[_CodeArray addObject:dict];
_dictCountry = [_CodeArray objectAtIndex:0];
NSString*Country_code=[NSString stringWithFormat:#"+%#",[_dictCountry objectForKey:lower]];
contactTextField.text=Country_code;
You can request to this url.
For get CountryCode or ip, region_name, city, long, lat
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:#"http://freegeoip.net/json/"]];
__block NSDictionary *json;
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(#"Countrycode: %#", json[#"country_code"]);
}];
Here the Objective C code
#import<CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
- (void)viewDidLoad{
CTTelephonyNetworkInfo *network_Info = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = network_Info.subscriberCellularProvider;
NSLog(#"country code is: %#", carrier.mobileCountryCode);
NSLog(#"ISO country code is: %#", carrier.mobileNetworkCode);
NSLog(#"diling code == %#",[self getCountryCode:carrier.isoCountryCode]);
}
- (NSString *)getCountryCode:(NSString *)countryISOCode{
NSDictionary * code = #{#"AF": #"93", #"AE": #"971", #"AL": #"355", #"AN": #"599", #"AS":#"1", #"AD": #"376", #"AO": #"244", #"AI": #"1", #"AG":#"1", #"AR": #"54",#"AM": #"374", #"AW": #"297", #"AU":#"61", #"AT": #"43",#"AZ": #"994", #"BS": #"1", #"BH":#"973", #"BF": #"226",#"BI": #"257", #"BD": #"880", #"BB": #"1", #"BY": #"375", #"BE":#"32",#"BZ": #"501", #"BJ": #"229", #"BM": #"1", #"BT":#"975", #"BA": #"387", #"BW": #"267", #"BR": #"55", #"BG": #"359", #"BO": #"591", #"BL": #"590", #"BN": #"673", #"CC": #"61", #"CD":#"243",#"CI": #"225", #"KH":#"855", #"CM": #"237", #"CA": #"1", #"CV": #"238", #"KY":#"345", #"CF":#"236", #"CH": #"41", #"CL": #"56", #"CN":#"86",#"CX": #"61", #"CO": #"57", #"KM": #"269", #"CG":#"242", #"CK": #"682", #"CR": #"506", #"CU":#"53", #"CY":#"537",#"CZ": #"420", #"DE": #"49", #"DK": #"45", #"DJ":#"253", #"DM": #"1", #"DO": #"1", #"DZ": #"213", #"EC": #"593", #"EG":#"20", #"ER": #"291", #"EE":#"372",#"ES": #"34", #"ET": #"251", #"FM": #"691", #"FK": #"500", #"FO": #"298", #"FJ": #"679", #"FI":#"358", #"FR": #"33", #"GB":#"44", #"GF": #"594", #"GA":#"241", #"GS": #"500", #"GM":#"220", #"GE":#"995",#"GH":#"233", #"GI": #"350", #"GQ": #"240", #"GR": #"30", #"GG": #"44", #"GL": #"299", #"GD":#"1", #"GP": #"590", #"GU": #"1", #"GT": #"502", #"GN":#"224",#"GW": #"245", #"GY": #"595", #"HT": #"509", #"HR": #"385", #"HN":#"504", #"HU": #"36", #"HK": #"852", #"IR": #"98", #"IM": #"44", #"IL": #"972", #"IO":#"246", #"IS": #"354", #"IN": #"91", #"ID":#"62", #"IQ":#"964", #"IE": #"353",#"IT":#"39", #"JM":#"1", #"JP": #"81", #"JO": #"962", #"JE":#"44", #"KP": #"850", #"KR": #"82",#"KZ":#"77", #"KE": #"254", #"KI": #"686", #"KW": #"965", #"KG":#"996",#"KN":#"1", #"LC": #"1", #"LV": #"371", #"LB": #"961", #"LK":#"94", #"LS": #"266", #"LR":#"231", #"LI": #"423", #"LT": #"370", #"LU": #"352", #"LA": #"856", #"LY":#"218", #"MO": #"853", #"MK": #"389", #"MG":#"261", #"MW": #"265", #"MY": #"60",#"MV": #"960", #"ML":#"223", #"MT": #"356", #"MH": #"692", #"MQ": #"596", #"MR":#"222", #"MU": #"230", #"MX": #"52",#"MC": #"377", #"MN": #"976", #"ME": #"382", #"MP": #"1", #"MS": #"1", #"MA":#"212", #"MM": #"95", #"MF": #"590", #"MD":#"373", #"MZ": #"258", #"NA":#"264", #"NR":#"674", #"NP":#"977", #"NL": #"31",#"NC": #"687", #"NZ":#"64", #"NI": #"505", #"NE": #"227", #"NG": #"234", #"NU":#"683", #"NF": #"672", #"NO": #"47",#"OM": #"968", #"PK": #"92", #"PM": #"508", #"PW": #"680", #"PF": #"689", #"PA": #"507", #"PG":#"675", #"PY": #"595", #"PE": #"51", #"PH": #"63", #"PL":#"48", #"PN": #"872",#"PT": #"351", #"PR": #"1",#"PS": #"970", #"QA": #"974", #"RO":#"40", #"RE":#"262", #"RS": #"381", #"RU": #"7", #"RW": #"250", #"SM": #"378", #"SA":#"966", #"SN": #"221", #"SC": #"248", #"SL":#"232",#"SG": #"65", #"SK": #"421", #"SI": #"386", #"SB":#"677", #"SH": #"290", #"SD": #"249", #"SR": #"597",#"SZ": #"268", #"SE":#"46", #"SV": #"503", #"ST": #"239",#"SO": #"252", #"SJ": #"47", #"SY":#"963", #"TW": #"886", #"TZ": #"255", #"TL": #"670", #"TD": #"235", #"TJ": #"992", #"TH": #"66", #"TG":#"228", #"TK": #"690", #"TO": #"676", #"TT": #"1", #"TN":#"216",#"TR": #"90", #"TM": #"993", #"TC": #"1", #"TV":#"688", #"UG": #"256", #"UA": #"380", #"US": #"1", #"UY": #"598",#"UZ": #"998", #"VA":#"379", #"VE":#"58", #"VN": #"84", #"VG": #"1", #"VI": #"1",#"VC":#"1", #"VU":#"678", #"WS": #"685", #"WF": #"681", #"YE": #"967", #"YT": #"262",#"ZA": #"27" , #"ZM": #"260", #"ZW":#"263"};
return [NSString stringWithFormat:#"+%#", [code objectForKey:[countryISOCode uppercaseString]]];
}
Swift 5 Support and using optionals here is my solution:
static func GetCountryCallingCode(countryRegionCode:String) -> String? {
let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593", "EG":"20", "ER": "291", "EE":"372","ES": "34", "ET": "251", "FM": "691", "FK": "500", "FO": "298", "FJ": "679", "FI":"358", "FR": "33", "GB":"44", "GF": "594", "GA":"241", "GS": "500", "GM":"220", "GE":"995","GH":"233", "GI": "350", "GQ": "240", "GR": "30", "GG": "44", "GL": "299", "GD":"1", "GP": "590", "GU": "1", "GT": "502", "GN":"224","GW": "245", "GY": "595", "HT": "509", "HR": "385", "HN":"504", "HU": "36", "HK": "852", "IR": "98", "IM": "44", "IL": "972", "IO":"246", "IS": "354", "IN": "91", "ID":"62", "IQ":"964", "IE": "353","IT":"39", "JM":"1", "JP": "81", "JO": "962", "JE":"44", "KP": "850", "KR": "82","KZ":"77", "KE": "254", "KI": "686", "KW": "965", "KG":"996","KN":"1", "LC": "1", "LV": "371", "LB": "961", "LK":"94", "LS": "266", "LR":"231", "LI": "423", "LT": "370", "LU": "352", "LA": "856", "LY":"218", "MO": "853", "MK": "389", "MG":"261", "MW": "265", "MY": "60","MV": "960", "ML":"223", "MT": "356", "MH": "692", "MQ": "596", "MR":"222", "MU": "230", "MX": "52","MC": "377", "MN": "976", "ME": "382", "MP": "1", "MS": "1", "MA":"212", "MM": "95", "MF": "590", "MD":"373", "MZ": "258", "NA":"264", "NR":"674", "NP":"977", "NL": "31","NC": "687", "NZ":"64", "NI": "505", "NE": "227", "NG": "234", "NU":"683", "NF": "672", "NO": "47","OM": "968", "PK": "92", "PM": "508", "PW": "680", "PF": "689", "PA": "507", "PG":"675", "PY": "595", "PE": "51", "PH": "63", "PL":"48", "PN": "872","PT": "351", "PR": "1","PS": "970", "QA": "974", "RO":"40", "RE":"262", "RS": "381", "RU": "7", "RW": "250", "SM": "378", "SA":"966", "SN": "221", "SC": "248", "SL":"232","SG": "65", "SK": "421", "SI": "386", "SB":"677", "SH": "290", "SD": "249", "SR": "597","SZ": "268", "SE":"46", "SV": "503", "ST": "239","SO": "252", "SJ": "47", "SY":"963", "TW": "886", "TZ": "255", "TL": "670", "TD": "235", "TJ": "992", "TH": "66", "TG":"228", "TK": "690", "TO": "676", "TT": "1", "TN":"216","TR": "90", "TM": "993", "TC": "1", "TV":"688", "UG": "256", "UA": "380", "US": "1", "UY": "598","UZ": "998", "VA":"379", "VE":"58", "VN": "84", "VG": "1", "VI": "1","VC":"1", "VU":"678", "WS": "685", "WF": "681", "YE": "967", "YT": "262","ZA": "27" , "ZM": "260", "ZW":"263"]
let countryDialingCode = prefixCodes[countryRegionCode]
return countryDialingCode
}
guard let regionCode = NSLocale.current.regionCode,
let callingCode = GetCountryCallingCode(countryRegionCode: regionCode )
else { return }
print("Region: \(regionCode) Country calling code is \(callingCode)")
import CoreTelephony
/// Method to get the iso calling code
///
/// - Returns: String
public static func getCallingCodePrefix() -> String {
let networkInfo = CTTelephonyNetworkInfo()
let phoneNumberKit = PhoneNumberKit()
if #available(iOS 12.0, *) {
if let carrier = networkInfo.serviceSubscriberCellularProviders?.map({ $0.1 }).first(where: { $0.isoCountryCode != nil }), let isoCode = carrier.isoCountryCode?.uppercased(), let prefixCode = phoneNumberKit.countryCode(for: isoCode) {
return "+" + String(prefixCode)
}
} else {
// Fallback on earlier versions
if let carrier = networkInfo.subscriberCellularProvider, let isoCode = carrier.isoCountryCode?.uppercased(), let prefixCode = phoneNumberKit.countryCode(for: isoCode) {
return "+" + String(prefixCode)
}
}
return "+"
}
Use this code to get the user's country in iOS:
func countryName(from countryCode: String) -> String {
if let name = (Locale.current as NSLocale).displayName(forKey: .countryCode, value: countryCode) {
return name
} else {
return countryCode
}
}
//Locale.current.regionCode this is used for Get user current country region code
countryName(from: Locale.current.regionCode ?? "")