Einzelnen Beitrag anzeigen

Rollo62
Online

Registriert seit: 15. Mär 2007
4.095 Beiträge
 
Delphi 12 Athens
 
#15

AW: Hat Jemand schonmal mit TestFairy herumgespielt ?

  Alt 13. Mai 2016, 16:47
Oha, und mit ein bischen umbenennen wirft er das raus:

Delphi-Quellcode:
{***********************************************************}
{                                                           }
{             CodeGear Delphi Runtime Library               }
{                                                           }
{   Copyright(c) 2012-2014 Embarcadero Technologies, Inc.   }
{                                                           }
{***********************************************************}

//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework libTestFairy
//

unit iOSapi.libTestFairy;

interface

uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.CocoaTypes,
iOSapi.Foundation,
iOSapi.UIKit;

type

// ===== Forward declarations =====
{$M+}
TestFairy = interface;

// ===== Framework typedefs =====
{$M+}
__builtin_va_list = Pointer;
__darwin_va_list = __builtin_va_list;
// ===== Interface declarations =====

TestFairyClass = interface(NSObjectClass)
['{32B9756A-9F33-47AE-AFBD-4A25D21BD540}']
[MethodName('begin:')]
{class} procedure begin(appToken: NSString); cdecl;
{ *
* Initialize a TestFairy session.
*
* @param appToken Your key as given to you in your TestFairy account
}


[MethodName('begin:withOptions:')]
{class} procedure beginWithOptions(appToken: NSString; withOptions: NSDictionary); cdecl;
{ *
* Initialize a TestFairy session with options.
*
* @param appToken Your key as given to you in your TestFairy account
* @param options A dictionary of options controlling the current session
}


{class} procedure setServerEndpoint(serverOverride: NSString); cdecl;
{ *
* Change the server endpoint for use with on-premise hosting. Please
* contact support or sales for more information. Must be called before begin
*
* @param serverOverride
}


{class} function version : NSString; cdecl;
{ *
* Returns SDK version (x.x.x) string
*
* @return version
}


{class} procedure hideView(view: UIView); cdecl;
{ *
* Hides a specific view from appearing in the video generated.
*
* @param view The specific view you wish to hide from screenshots
*
}


{class} procedure hideWebViewElements(selector: NSString); cdecl;
{ *
* Hides a specific html element from appearing in your UIWebView
*
* @param selector The specific selector you wish to hide from screenshots. Multiple selectors can be comma separated
}


{class} procedure pushFeedbackController; cdecl;
{ *
* Pushes the feedback view controller. Hook a button
* to this method to allow users to provide feedback about the current
* session. All feedback will appear in your build report page, and in
* the recorded session page.
*
}


{class} procedure sendUserFeedback(feedbackString: NSString); cdecl;
{ *
* Send a feedback on behalf of the user. Call when using a in-house
* feedback view controller with a custom design and feel. Feedback will
* be associated with the current session.
*
* @param feedbackString Feedback text
}


{class} procedure updateLocation(locations: NSArray); cdecl;
{ *
* Proxy didUpdateLocation delegate values and these
* locations will appear in the recorded sessions. Useful for debugging
* actual long/lat values against what the user sees on screen.
*
* @param locations Array of CLLocation. The first object of the array will determine the user location
}


{class} procedure checkpoint(name: NSString); cdecl;
{ *
* Marks a checkpoint in session. Use this text to tag a session
* with a checkpoint name. Later you can filter sessions where your
* user passed through this checkpoint, for bettering understanding
* user experience and behavior.
*
* @param name The checkpoint name
}


{class} procedure setCorrelationId(correlationId: NSString); cdecl;
{ *
* Sets a correlation identifier for this session. This value can
* be looked up via web dashboard. For example, setting correlation
* to the value of the user-id after they logged in. Can be called
* only once per session (subsequent calls will be ignored.)
*
* @param correlationId Id for the current session
}


[MethodName('identify:')]
{class} procedure identify(correlationId: NSString); cdecl;
{ *
* Sets a correlation identifier for this session. This value can
* be looked up via web dashboard. For example, setting correlation
* to the value of the user-id after they logged in. Can be called
* only once per session (subsequent calls will be ignored.)
*
* @param correlationId Id for the current session
}


[MethodName('identify:traits:')]
{class} procedure identifyTraits(correlationId: NSString; traits: NSDictionary); cdecl;
{ *
* Sets a correlation identifier for this session. This value can
* be looked up via web dashboard. For example, setting correlation
* to the value of the user-id after they logged in. Can be called
* only once per session (subsequent calls will be ignored.)
*
* @param correlationId Id for the current session
* @param traits Attributes and custom attributes to be associated with this session
}


{class} procedure pause; cdecl;
{ *
* Pauses the current session. This method stops recoding of
* the current session until resume has been called.
*
* @see resume
}


{class} procedure resume; cdecl;
{ *
* Resumes the recording of the current session. This method
* resumes a session after it was paused.
*
* @see pause
}


{class} function sessionUrl : NSString; cdecl;
{ *
* Returns the address of the recorded session on testfairy's
* developer portal. Will return nil if recording not yet started.
*
* @return session URL
}


{class} procedure takeScreenshot; cdecl;
{ *
* Takes a screenshot.
*
}


end;
TestFairy = interface(NSObject)
['{D9486008-3B18-43B2-87EB-CFD02703D7B5}']
end;

TTestFairy = class(TOCGenericImport<TestFairyClass, TestFairy>) end;
PTestFairy = Pointer;

// ===== Exported string consts =====

function TFSDKIdentityTraitNameKey: NSString;
function TFSDKIdentityTraitEmailAddressKey: NSString;
function TFSDKIdentityTraitBirthdayKey: NSString;
function TFSDKIdentityTraitGenderKey: NSString;
function TFSDKIdentityTraitPhoneNumberKey: NSString;
function TFSDKIdentityTraitWebsiteAddressKey: NSString;
function TFSDKIdentityTraitAgeKey: NSString;
function TFSDKIdentityTraitSignupDateKey: NSString;
function TFSDKEnableCrashReporterKey: NSString;
function TestFairyDidShakeDevice: NSString;
function TestFairyWillProvideFeedback: NSString;
function TestFairyDidCancelFeedback: NSString;
function TestFairyDidSendFeedback: NSString;


// ===== External functions =====

const
liblibTestFairy = '/System/Library/Frameworks/libTestFairy.framework/libTestFairy';
procedure TFLog(format: Pointer {NSString}); cdecl; external liblibTestFairy name _PU + 'TFLog';
procedure TFLogv(format: Pointer {NSString}; arg_list: array of const); cdecl; external liblibTestFairy name _PU + 'TFLogv';


implementation

{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;

var
libTestFairyModule: THandle;

{$ENDIF IOS}


function TFSDKIdentityTraitNameKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitNameKey');
end;

function TFSDKIdentityTraitEmailAddressKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitEmailAddressKey');
end;

function TFSDKIdentityTraitBirthdayKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitBirthdayKey');
end;

function TFSDKIdentityTraitGenderKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitGenderKey');
end;

function TFSDKIdentityTraitPhoneNumberKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitPhoneNumberKey');
end;

function TFSDKIdentityTraitWebsiteAddressKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitWebsiteAddressKey');
end;

function TFSDKIdentityTraitAgeKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitAgeKey');
end;

function TFSDKIdentityTraitSignupDateKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKIdentityTraitSignupDateKey');
end;

function TFSDKEnableCrashReporterKey: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TFSDKEnableCrashReporterKey');
end;

function TestFairyDidShakeDevice: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TestFairyDidShakeDevice');
end;

function TestFairyWillProvideFeedback: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TestFairyWillProvideFeedback');
end;

function TestFairyDidCancelFeedback: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TestFairyDidCancelFeedback');
end;

function TestFairyDidSendFeedback: NSString;
begin
  Result := CocoaNSStringConst(liblibTestFairy, 'TestFairyDidSendFeedback');
end;

{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
libTestFairyModule := dlopen(MarshaledAString(liblibTestFairy), RTLD_LAZY);

finalization
dlclose(libTestFairyModule);
{$ENDIF IOS}

end.
Das sieht schon besser aus, werde ich mal Testen.

Rollo
  Mit Zitat antworten Zitat