Get record from Xamarin.iOS in Xamarin.Forms - xamarin

i need to get record from keychain via: SecureStorage.GetAsync("xxx");
In Xamarin.iOS app i have this:
var s = new SecRecord(SecKind.GenericPassword)
{
Label = "Item Label",
Description = "Item description",
Account = "Account",
Service = "Service",
Comment = "Your comment here",
ValueData = NSData.FromString("Something"),
Generic = NSData.FromString("foo")
};
var err = SecKeyChain.Add(s);
I tried make native iOS app and i can get from Keychain value of "Account", but no in Xamarin.Forms. Where Xamarin.forms store encrypted data please? Is possible to get(share) some values from iOS in Forms? For example FCM token from Firebase?
Iam new in Xamarin
Thank you for response

Where Xamarin.forms store encrypted data
Essentials SecureStorage on iOS uses a SecRecord for storage under an Account name (alias) that is constructed via:
// Special Alias that is only used for Secure Storage. All others should use: Preferences.GetPrivatePreferencesSharedName
internal static readonly string Alias = $"{AppInfo.PackageName}.xamarinessentials";
re: https://github.com/xamarin/Essentials/tree/develop/Xamarin.Essentials/SecureStorage

Related

Adaptive Cards: Payment Request

I am currently working on a bot project where i am trying to utilize Microsoft adaptive cards to try send a PaymentRequest to the user. I created a dummy paymentrequest object and inserted it into a Hero card like the documentation says.
var methodList = new List<PaymentMethodData>();
var method = new PaymentMethodData()
{Data = new {supportedNetworks = new[] { "visa", "mastercard", "amex", "discover", "diners", "jcb", "unionpay"} }, SupportedMethods = new[] { "https://bobpay.xyz/pay" } };
methodList.Add(method);
var details = new PaymentDetails {};
var test = new PaymentRequest(null, methodList, details);
var heroCard = new HeroCard
{
Title = "Bob",
Subtitle = "The Builder",
Text = "Kunnen wij het maken!",
Images = new List<CardImage>
{
new CardImage
{
Url = "https://m.media-amazon.com/images/M/MV5BNjRlYjgwMWMtNDFmMy00OWQ0LWFhMTMtNWE3MTU4ZjQ3MjgyXkEyXkFqcGdeQXVyNzU1NzE3NTg#._V1_CR0,45,480,270_AL_UX477_CR0,0,477,268_AL_.jpg"
}
},
Buttons = new List<CardAction>
{
new CardAction
{
Title = "Buy",
Type = PaymentRequest.PaymentActionType,
Value = test,
}
}
};
replyMessage.Attachments.Add(heroCard.ToAttachment());
await context.PostAsync(replyMessage);
I took out a bunch of parameters from the PaymentRequest constructor because i was experimenting with trying to get some kind of feedback. With this i get back nothing but this url which crashed the browser when i try to run it.
"content": {
"buttons": [
{
"title": "Buy",
"type": "openUrl",
"value": "payment://{\"methodData\":[{\"supportedMethods\":[\"https://bobpay.xyz/pay\"],\"data\":{}}],\"details\":{}}"
}
],
I can't find any documentation on how to do this properly but it doesnt seem to say it is deprecated on the documention. I am using bot framework v3 if that helps. I feel like even without some parameters in the PaymentRequest it should still give me something when i click the button.
As stated in this documentation: bot-builder-dotnet-request-payment In order to use the Bot Builder Payments library, you must first:
Create and activate a Stripe account if you don't have one already.
Sign in to Seller Center with your Microsoft account.
Within Seller Center, connect your account with Stripe.
Within Seller Center, navigate to the Dashboard and copy the value of
MerchantID.
Update your bot's Web.config file to set MerchantId to the value that
you copied from the Seller Center Dashboard.
At this time, the Bot Framework SDK supports only Stripe payments directly. If you are using some other provider, you will need to add support for it manually.
Also note: as of 2.25.2019, Bot Builder V4 sdk does not have payments support built in. The Bot Builder V3 sdk does: https://github.com/Microsoft/BotBuilder-Samples/tree/v3-sdk-samples/CSharp/sample-payments (Also, the Bot Framework Emulator V4 does not yet support payments: https://github.com/Microsoft/BotFramework-Emulator/issues/1324 The V3 emulator can be downloaded from here: https://github.com/Microsoft/BotFramework-Emulator/releases/tag/v3.5.37 )

Google authentication Xamarin invalid redirect uri

I need to make authentication using Google for my app (Xamarin Android Native). I used this article. I passed step by step. Also I created client id in Google Developer Console. But I have an error. The package name is displayed on the screenshot. What can be wrong with this?
public const string RedirectUrl = "com.xplorpal.pal_:/oauth2redirect";
_auth = new OAuth2Authenticator(clientId, string.Empty, scope,
new Uri(AuthorizeUrl),
new Uri(redirectUrl),
new Uri(AccessTokenUrl),
null, IsUsingNativeUI);
I think the problem is the underscore in the redirect URL:
public const string RedirectUrl = "com.xplorpal.pal:/oauth2redirect";
_auth = new OAuth2Authenticator(clientId, string.Empty, scope,
new Uri(AuthorizeUrl),
new Uri(redirectUrl),
new Uri(AccessTokenUrl),
null, IsUsingNativeUI);
Here you can find more info about why the UriFormatException is thrown. https://msdn.microsoft.com/it-it/library/z6c2z492(v=vs.110).aspx

Send email with subject and body Xamarin Forms

I am using the following code in my Xamarin.Forms project to open the native email client on the device with some information prepopulated in the body, but the email client on Android opens without a set body and subject; it only has the mailto property.
The following code works for iOS, but on Android, it opens the email clientand only displays mailto.
string body = "Name : "+"\r\n" +NameLabel.Text +"Phone : "+Phonelabel.Text +"\r\n"+ "Email : "+ EmailLabel.Text ;
string strMailTo = #"mailto:test#gmail.com?Subject="profile"&Body="+body;
Device.OpenUri(new Uri(strMailTo));
I think you can try this plugin. I have used for some apps and works fine. It's PCL.
https://www.nuget.org/packages/Xam.Plugins.Messaging/
I have code that uses Device.OpenUri from Xamarin Forms. I think perhaps your quotes are confusing it:
Device.OpenUri(new Uri("mailto:email#test.com?subject=MobileTing&body=A message for you consideration."));
I used in Xamarin.Forms DependencyService and this code:
var email = new Intent (Android.Content.Intent.ActionSend);
email.PutExtra (Android.Content.Intent.ExtraEmail,
new string[]{"person1#xamarin.com", "person2#xamrin.com"} );
email.PutExtra (Android.Content.Intent.ExtraCc,
new string[]{"person3#xamarin.com"} );
email.PutExtra (Android.Content.Intent.ExtraSubject, "Hello Email");
email.PutExtra (Android.Content.Intent.ExtraText,
"Hello from Xamarin.Android");
it full example

Google calendar api CalendarList List return empty element

EDIT: The original poster asked this for C#, but the same problem occurs regardless of the library used, and its solution is language independent.
Using C# lib,
string service_account = "myaccount#developer.gserviceaccount.com";
var certificate = new X509Certificate2(#"pathtomy-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(service_account)
{
Scopes = new[] { CalendarService.Scope.Calendar }
}.FromCertificate(certificate));
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "My project name",
});
var calendarList = service.CalendarList.List().Execute();
IList<CalendarListEntry> items = calendarList.Items;
items is empty. On https://developers.google.com/google-apps/calendar/v3/reference/calendarList/list, when I try the api, I get the good result.
I really don't understand why I don't have any result : seems like if the service_account do not have the same calendar as my gmail account linked to.
Any suggestion ?
Thanks.
The solution is to share the existing calendar with the service account
<paste-your-account-here>#developer.gserviceaccount.com
(You can find the account in question under the credentials tab in Google Developers Console, it's called 'EMAIL ADDRESS')

Linking activities to an account in CRM 4.0

I am developing an application using the CRM 4.0 web service interface and need to programatically create a phone call record and link it to an account record. I can see how to create the records but I am not sure how to link the phone call to the account. Any help would be much appreciated.
Thanks
Nigel
You can't directly link an activity (like phone call) to an entity (like account). You must use the activityparty object to do it.
To do it follow these steps (I am assuming the account exists):
phonecall newPhoneCall = new phonecall ();
// Set the properties of the newPhoneCall.
newPhoneCall.subject = "Test newPhoneCall";
newPhoneCall.description = "New newPhoneCall";
// Create the party sending and receiving the newPhoneCall.
activityparty party = new activityparty();
// Set the properties of Activityparty.
party.partyid = new Lookup();
party.partyid.type = EntityName.account.ToString();
party.partyid.Value = existingAccount.accountId;
// The party sends and receives the newPhoneCall.
newPhoneCall.from = new activityparty[] { };
newPhoneCall.to = new activityparty[] { party };
Then create the phone call activity as normal.

Resources