'Für crash reports framework
#AdditionalLib: KSCrash.framework.3
#AdditionalLib: MessageUI.framework
#AdditionalLib: SystemConfiguration.framework
#AdditionalLib: libc++.dylib
#AdditionalLib: libz.dylib
Sub Class_Globals
'Für crash reports framework
Private xui As XUI
Private reporter As NativeObject
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
#if RELEASE
If App.IsSimulator = False Then
CreateReporter
SendReportsIfNeeded
End If
#end if
End Sub
Sub SendReportsIfNeeded As ResumableSub
Dim no As NativeObject
no = no.Initialize("KSCrash").RunMethod("sharedInstance", Null)
Dim reports As Int = no.GetField("reportCount").AsNumber
Log($"Number of reports: ${reports}"$)
'Page1.Title = reports
If reports > 0 Then
Sleep(0)
Dim sf As Object = xui.Msgbox2Async("The app crashed last time it was launched. Please help us improve and send a crash report?", _
"", "Yes", "No", "", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
Dim nme As NativeObject = Me
nme.RunMethod("sendReports:", Array(reporter))
Else
no.RunMethod("deleteAllReports", Null)
End If
End If
Return True
End Sub
Sub CreateReporter
reporter = reporter.Initialize("KSCrashInstallationEmail").RunMethod("sharedInstance", Null)
Dim recipients As List = Array("[email protected]") '<------------------------------------------- change!!!!!!!!!!!!!
reporter.SetField("recipients", recipients)
reporter.SetField("reportStyle", 1) 'KSCrashEmailReportStyleApple
reporter.SetField("subject", "Crash Report")
reporter.SetField("message", "This Is a crash report")
reporter.SetField("filenameFmt", "crash-report-%d.txt.gz")
reporter.RunMethod("install", Null)
End Sub
#if OBJC
#import <KSCrash/KSCrashFramework.h>
- (void) sendReports:(KSCrashInstallation*)installation {
[installation sendAllReportsWithCompletion:^(NSArray* reports, BOOL completed, NSError* error)
{
if(completed)
{
NSLog(@"Sent %d reports", (int)[reports count]);
}
else
{
NSLog(@"Failed to send reports: %@", error);
}
}];
}
#End If