I am currently integrating HockeyApp into my IOS project on Xamarin and I would like to be able to attach the username to the crash reports but I cant figure out how .Is it even possible ?
You can attach the username and other metadata to the report with the following sample:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure(AppID);
manager.UserEmail = "user#contoso.com";
manager.UserId = "UserID";
manager.UserName = "UserName";
manager.DebugLogEnabled = true;
manager.StartManager();
manager.Authenticator.AuthenticateInstallation(); // This line is obsolete in crash only builds
global::Xamarin.Forms.Forms.Init();
LoadApplication(CreateApp());
return base.FinishedLaunching(app, options);
}
Related
Build environment:
Macbook M1
vscode(1.69.0) as well as vs2022 (17.3)
Steps to reproduce:
create new Maui app
add nuget package "Microsoft.Extensions.Http" Version="6.0.0" to project
Modify MauiProgram.cs:
builder.Services.AddHttpClient<EndPointAHttpClient>(client =>
{
var EndPointA = "https://www.montemagno.com/";
client.BaseAddress = new Uri(EndPointA);
});
public class EndPointAHttpClient
{
public EndPointAHttpClient(HttpClient client)
{
Client = client;
}
public HttpClient Client { get; }
}
Publish:
dotnet publish <project.csproj> -f:net6.0-ios -c:Release /p:ServerAddress=<xxx.xxx.xxx.xxx> /p:ServerUser=user /p:TcpPort=58181 /p:ServerPassword=pwd -p:AotAssemblies=false
Install on iphone using Transporter/TestFlight
CRASHES WHEN OPENING THE APP
Please let me know:
1. Is there any demo code that works
2. Kindly provide advise on how I can use HttpClient in a .net Maui app
Use the code found here. https://github.com/dotnet/maui-samples/tree/main/6.0/WebServices/TodoREST/TodoREST/Services
Grab the RestService, IRestService, HttpsClientHandlerService and IHttpsClientHandlerService.
Get the Contstants file as well.
https://github.com/dotnet/maui-samples/blob/main/6.0/WebServices/TodoREST/TodoREST/Constants.cs
Makes sure you add your Url to the HttpsClientHandlerService like so. I was getting a System.Net.WebException: Error: TrustFailure. The only way I was able to catch what was happening was using Sentry.io. I guessed that this might be the problem.
public bool IsSafeUrl(NSUrlSessionHandler sender, string url, Security.SecTrust trust)
{
if (url.StartsWith("https://localhost") || url.StartsWith("https://yourservice.azurewebsites.net"))
return true;
return false;
}
Then change this line.
var handler = new NSUrlSessionHandler
{
TrustOverrideForUrl = IsSafeUrl
};
I'm using the latest stable package of Plugin.FirebaseAuth (4.1.0). But when I try to call the SignInWithEmailAndPasswordAsync(email, password) when using the iOS simulator. I get an exception?
Method:
public async Task<bool> SignIn(string email, string password)
{
try
{
var result = await CrossFirebaseAuth.Current.Instance.SignInWithEmailAndPasswordAsync(email, password);
var token = await result.User.GetIdTokenAsync(true);
Preferences.Set("MyFirebaseRefreshToken", token);
AccountManager.CurrentUserId = result.User.Uid;
return true;
}
catch (FirebaseAuthException ex)
{
Console.WriteLine(ex.Reason);
await App.Current.MainPage.DisplayAlert($"Alert", (ex.Reason.ToString()), "OK");
return false;
}
}`
Error:
If it only happens to ios, that's maybe because you didn't add the Team ID prefix before your App ID. Like this:
Auth.auth().useUserAccessGroup("XK********.com.matkonit.SharedItems")
You can refer to this page.
Ok So the issue turns out to be with the simulator for iOS.
The fix:
You'll need an apple developer account, and a provisioning profile. You'll also need a custom entitlements.plist
I have a "hard to read" crashlytics log in a live Xamarin iOS app. This issue affects almost 80% of the users and I am struggling to decipher it.
Please have a look at the log in this gist
I have uploaded the dSYM file in the Crashlytics dashboard but the log remains the same. Is it normal for a Xamarin App this type of log?
I do not even know what source file of the app causes the crash.
I have the following code in AppDelegate.cs:
override public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions){
//...
Setup.EnableCrashReporting (() => {
var crashlytics = Crashlytics.SharedInstance;
crashlytics.DebugMode = true;
Crashlytics.StartWithAPIKey ("my_key");
Fabric.With (new NSObject[]{ crashlytics });
AppDomain.CurrentDomain.UnhandledException += AppDomain_CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
}, Path.GetFileNameWithoutExtension (typeof(AppDelegate).Module.Name));
}
and the following methods:
void TaskScheduler_UnobservedTaskException (object sender, UnobservedTaskExceptionEventArgs e)
{
var ex = e.Exception;
Setup.CaptureManagedInfo(ex);
Setup.CaptureStackFrames(ex);
Setup.ThrowExceptionAsNative(ex);
}
void AppDomain_CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
{
Setup.CaptureManagedInfo(e.ExceptionObject);
Setup.CaptureStackFrames(e.ExceptionObject);
Setup.ThrowExceptionAsNative(e.ExceptionObject);
}
Am I missing something on Fabric configuration here?
I'm trying to use Xamarin native iOS library to authenticate with Facebook and access Graph API.
According to release 4.0.1.1 notes for the component (I didn't find any other documentation anywhere)
FBSDKTokenCachingStrategy. No alternative. LoginManager class caches
tokens to keychain automatically. You can observe token changes to do
manual post processing.
However this doesn't seem to be happening. When my iOS application starts I create LoginManager instance and call Init. However after that AccessToken.CurrentAccessToken is still null. It is only populated with data after I call LogInWithReadPermissionsAsync on the LoginManager.
Am I missing something or is it a bug.
Here's my code.
public bool IsLoggedIn
{
get
{
return AccessToken.CurrentAccessToken != null &&
AccessToken.CurrentAccessToken.ExpirationDate.ToDateTime() > DateTime.Now;
}
}
public Task<AccessToken> FacebookLoginInternal()
{
lock (monitor)
{
if (_loginTask == null)
{
LoginManager manager = new LoginManager();
manager.Init();
if (IsLoggedIn)
{
var ts = new TaskCompletionSource<AccessToken>();
ts.SetResult(AccessToken.CurrentAccessToken);
_loginTask = ts.Task;
}
else
{
var loginResult = manager.LogInWithReadPermissionsAsync(
new string[] { "email", "user_friends" });
_loginTask = loginResult.ContinueWith(r =>
{
return r.Result.Token;
});
}
}
return _loginTask;
}
As per response from Xamarin support (thank you!)
The following code fixes the issue:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
return ApplicationDelegate.SharedInstance.FinishedLaunching(app, options);
}
This would seem to be expected behavior? You won't have a token until you log in, and this seems expected. I believe you may have misunderstood the note you pasted. It does not say that the token is cached as soon as you instantiate LoginManager or call Init on it, just that LoginManager will cache the token. It can't cache a token until a token is generated when you log in. That is why (I believe) Guilherme Torres Castro asked if the token is the same after a second call to LogInWithReadPermissionsAsync. If so, then the token was cached upon login.
Update: Communication with the OP via other channels indicates that I misunderstood. Log in is not maintained after app termination and relaunch, whereas in the native Obj-C Facebook iOS SDK it is. A bug has been filed: https://bugzilla.xamarin.com/show_bug.cgi?id=30287
I am developing one application in that i have contact details ,when i click the contact number it will ask some option like call or sms or add to phone contact. I implemented call and sms, But when am trying to implement add number ,name ,email in to the phone contact am getting struggle. the below code am used for add contact
try
{
ContactList contacts = null;
try {
contacts = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
} catch (PIMException e) {
// An error occurred
return;
}
Contact contact = contacts.createContact();
String[] name = new String[ contacts.stringArraySize( Contact.NAME) ];
name[Contact.NAME_GIVEN] = "Kate";
name[Contact.NAME_FAMILY] = "Turner";
contact.addStringArray(Contact.NAME, Contact.ATTR_NONE,name);
contact.addString(Contact.EMAIL, Contact.ATTR_NONE, emailAddressTo);
contact.addString(Contact.TEL,Contact.ATTR_NONE,"6776787"//this for voice call number.
AddressBookArguments entry = new AddressBookArguments(AddressBookArguments.ARG_NEW, contact);
Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, entry);
}
catch (Throwable t)
{
}
}
This above code work fine but when am trying to add mobile number like this
contact.addString(Contact.ATTR_MOBILE,Contact.ATTR_NONE,"mobile Number");
am getting exception Illegal argument Exception, I don't know how to add the mobile number here,Can anyone help me to solve this?
You can do like this,
if (contacts.isSupportedField(Contact.TEL)) {
contact.addString(Contact.TEL, Contact.ATTR_MOBILE, "1234567890");
}
See this IBM developerWorks article for more info:
Develop mobile apps with Personal Information Management