Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Add Lookback SDK support
Browse files Browse the repository at this point in the history
Adds binding for [Lookback](http://lookback.io), which allows users to record experiences in your application and upload them for your review. Whether used for bug reports, feature requests, or general communication, this tool is fun and seriously useful.
  • Loading branch information
socialtopher committed Aug 21, 2014
1 parent 9f21417 commit 9f4d983
Show file tree
Hide file tree
Showing 20 changed files with 895 additions and 0 deletions.
144 changes: 144 additions & 0 deletions Lookback/binding/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using System;
using System.Drawing;
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace LookbackSDK
{
[BaseType (typeof(NSObject), Name="Lookback")]
public interface Lookback
{
[Static]
[Export ("setApplicationId:clientKey:")]
void SetAppId (string applicationId, string clientKey);

[Static]
[Export ("offlineMessagesEnabled:")]
void OfflineMessagesEnabled (bool enabled);

[Static]
[Export ("errorMessagesEnabled:")]
void ErrorMessagesEnabled (bool enabled);

[Static]
[Export ("getApplicationId")]
string ApplicationId{ get; }

[Static]
[Export ("getClientKey")]
string ClientKey{ get; }


/// <summary>
/// In your ApplicationDidFinishLaunching or similar, call this method to prepare Lookback for use, using the App Token from your integration guide at lookback.io.
/// </summary>
/// <param name="appToken">A string identifying your app, received from your app settings at http://lookback.io</param>
[Static]
[Export ("setupWithAppToken:")]
void SetupWithAppToken (string appToken);

/// <summary>
/// Shared instance of Lookback to use from your code. You must call SetupWithAppToken before calling this method.
/// </summary>
/// <value>Shared instance of Lookback</value>
[Static]
[Export ("lookback")]
Lookback lookback { get; set; }

/// <summary>
/// Whether Lookback is set to recording. You can either set this programmatically, or use LookbackSettingsViewController to let the user activate it.
/// </summary>
/// <value>Whether or not lookback is enabled.</value>
[Export ("enabled")]
bool Enabled { get; set; }

/// <summary>
/// If enabled, displays UI to start recording when you shake the device. Default NO. This is just a convenience method. It's roughly equivalent to implementing
/// -[motionEnded:withEvent:] in your first responder, and modally displaying a
/// LookbackSettingsViewController on the window's root view controller.
/// </summary>
/// <value>Whether or not shake to record is enabled.</value>
[Export ("shakeToRecord")]
bool ShakeToRecord { get; set; }

/// <summary>
/// Is Lookback paused? Lookback will pause automatically when app is inactive. The value of this property is undefined if recording is not enabled (as there is nothing to pause).
/// </summary>
/// <value>Whether or not lookback is paused.</value>
[Export ("isPaused")]
bool Paused { get; }

/// <summary>
/// Identifier for the user who's currently using the app. You can filter on this property at lookback.io later. If your service has log in user names, you can use that here. Optional. http://lookback.io/docs/log-username
/// </summary>
/// <value>The lookback user identifier.</value>
[Export ("userIdentifier", ArgumentSemantic.Copy)]
string UserIdentifier { get; set; }

/// <summary>
/// Track user navigation manually, if automatic tracking has been disabled. @see LookbackAutomaticallyLogViewAppearance
/// </summary>
/// <param name="viewIdentifier">Unique human readable identifier for a specific view</param>
[Export ("enteredView:")]
void EnteredView (string viewIdentifier);

/// <summary>
/// Track user navigation manually, if automatic tracking has been disabled. @see LookbackAutomaticallyLogViewAppearance
/// </summary>
/// <param name="viewIdentifier">Unique human readable identifier for a specific view</param>
[Export ("exitedView:")]
void ExitedView (string viewIdentifier);

/*! Lookback automatically sets a screen recording framerate that is suitable for your
device. However, if your app is very performance intense, you might want to decrease
the framerate at which Lookback records to free up some CPU time for your app. This
multiplier lets you adapt the framerate that Lookback chooses for you to something
more suitable for your app.
Default value: 1.0
Range: 0.1 to 1.0
@see LookbackScreenRecorderFramerateLimitKey
*/
[Export ("framerateMultiplier")]
float FramerateMultiplier { get; set; }

/// <summary>
/// For debugging
/// </summary>
/// <value>The lookback application token.</value>
[Export ("appToken")]
string AppToken { get; }
}

[BaseType (typeof (UIView))]
[Category]
interface LookbackConcealing {
[Static]
[Export ("lookback_shouldBeConcealedInRecordings")]
bool LookbackShouldBeConcealedInRecordings { get; set; }
}

/// <summary>
/// Class with helpers for starting and stopping recording.
/// </summary>
[BaseType (typeof (UIViewController))]
interface LookbackRecordingViewController {
/// <summary>
/// Creates a window on top of the app and displays this view controller.
/// </summary>
/// <value> Whether to present the vc with an animation. </value>
[Static]
[Export ("presentOntoScreenAnimated:")]
LookbackRecordingViewController PresentOntoScreenAnimated (bool animated);

/// <summary>
/// Destroys the overlay window and removes the receives from the screen.
/// </summary>
/// <value> Whether to do so in an animated fashion. </value>
[Export ("dismissAnimated:")]
void DismissAnimated (bool animated);
}
}

3 changes: 3 additions & 0 deletions Lookback/binding/Lookback.linkwith.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System;
using MonoTouch.ObjCRuntime;
[assembly: LinkWith ("Lookback", LinkTarget.ArmV7 | LinkTarget.ArmV7s | LinkTarget.Simulator, ForceLoad = true, Frameworks="AVFoundation AudioToolbox CoreVideo CoreMedia SystemConfiguration MediaPlayer QuartzCore")]
54 changes: 54 additions & 0 deletions Lookback/binding/LookbackSDK.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{53954B4D-9805-46F7-B2FD-DABCBA658B45}</ProjectGuid>
<ProjectTypeGuids>{F5B4F3BC-B597-4E2B-B552-EF5D8A32436F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>LookbackSDK</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>LookbackSDK</AssemblyName>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="monotouch" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Xamarin.ObjcBinding.CSharp.targets" />
<ItemGroup>
<Compile Include="Lookback.linkwith.cs">
<DependentUpon>Lookback</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ObjcBindingNativeLibrary Include="Lookback" />
</ItemGroup>
</Project>
45 changes: 45 additions & 0 deletions Lookback/binding/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
MONOXBUILD=/Library/Frameworks/Mono.framework/Commands/xbuild

# If you update the binding to a newer Lookback version don't forget to change
# the Git TAG of newer the version you are binding against
VERSION=0.6.4

all: init LookbackHD.dll LookbackSafe.dll wrapup

init:
rm -rf HD/ Safe/ bin/ obj/ Lookback *.userprefs

lookback-ios-sdk:
@if test -f ../lookback/HD/Lookback.framework/Versions/A/Lookback; then \
echo "Lookback SDK located."; \
else \
echo "Cannot find Lookback SDK. "; \
echo "Initiating Lookback SDK download."; \
open https://s3-eu-west-1.amazonaws.com/lookback-public/sdk/lookback-sdk-$(VERSION).zip; \
fi

LookbackHD: lookback-ios-sdk
cp ../lookback/HD/Lookback.framework/Versions/A/Lookback Lookback
cp -R ../lookback/HD/Lookback.framework/Versions/A/Resources/ Lookback-Resources

LookbackHD.dll: LookbackHD
$(MONOXBUILD) /p:Configuration=Release LookbackSDK.csproj
mkdir HD
cp bin/Release/LookbackSDK.dll HD/LookbackSDK.dll

LookbackSafe: lookback-ios-sdk
cp ../lookback/Safe/Lookback.framework/Versions/A/Lookback Lookback
cp -R ../lookback/Safe/Lookback.framework/Versions/A/Resources/ Lookback-Resources

LookbackSafe.dll: LookbackSafe
$(MONOXBUILD) /p:Configuration=Release LookbackSDK.csproj
mkdir Safe
cp bin/Release/LookbackSDK.dll Safe/LookbackSDK.dll

wrapup:
rm -rf bin/ obj/ Lookback *.userprefs

prepare: Lookback

clean:
-rm -rf *.a *.dll *.mdb bin/ obj/ HD/ Safe/ *.userprefs *.zip *.storyboard *.png ../lookback/ Lookback Lookback-Resources ../samples/LookbackSample/GFSettings.storyboard ../samples/LookbackSample/lookback*.png ../samples/LookbackSample/bin ../samples/LookbackSample/obj
6 changes: 6 additions & 0 deletions Lookback/binding/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System;

namespace LookbackSDK
{
}

48 changes: 48 additions & 0 deletions Lookback/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Lookback binding for Xamarin.iOS
_version 0.6.3 (May 13, 2014)_

## Instructions to integrate Lookback into your iOS project:

1. sign-up for [Lookback](http://www.lookback.io/) at their site.
2. download and expand the Lookback SDK to the /Lookback folder.
3. run **make** from the /binding folder.
4. if building an ad-hoc release, add a reference to LookbackSDK.dll in the /binding/HD folder; if building an app store release, use the .dll in the /binding/Safe folder.
5. Copy resources from the binding/Lookback-Resources folder to your project.
6. Ensure that the storyboard file's build action is set to InterfaceDefinition, and that the image files are set as bundle resources.
7. Add the InitializeLookback() function below to your project to enable within your application, or roll your own:

private void InitializeLookback ()
try {
LookbackSDK.Lookback.SetupWithAppToken("<your Lookback token>");
LookbackSDK.Lookback lb = LookbackSDK.Lookback.lookback;
lb.ShakeToRecord = true;
lb.UserIdentifier = "<user's identifier>";

//note: you can change these defaults to meet your needs.
NSUserDefaults.StandardUserDefaults.SetBool (true, "com.thirdcog.lookback.preview.enabled");
NSUserDefaults.StandardUserDefaults.SetBool (true, "com.thirdcog.lookback.autosplit");

//this delegate returns a url for the Lookback session.
NSNotificationCenter.DefaultCenter.AddObserver ("com.thirdcog.lookback.notification.startedUploading", delegate (NSNotification n)
{
NSUrl url = (NSUrl)n.UserInfo.ObjectForKey("com.thirdcog.lookback.notification.startedUploading.destinationURL".ToNSString());
UIPasteboard.General.Url = url;});}

catch {
Console.WriteLine ("Unable to initialize Lookback.");
}
}
}

//Extension method to support Lookback initialization.
public static class ExtensionMethods
{
public static NSString ToNSString(this String str)
{
return new NSString(str);
}
}

## Building the LookbackSample application
1. follow steps 1-3 listed above.
2. run **make** from the /samples folder.
68 changes: 68 additions & 0 deletions Lookback/samples/LookbackSample/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using LookbackSDK;

namespace LookbackSample
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
public override UIWindow Window {
get;
set;
}
// This method is invoked when the application is about to move from active to inactive state.
// OpenGL applications should use this method to pause.
public override void OnResignActivation (UIApplication application)
{
}
// This method should be used to release shared resources and it should store the application state.
// If your application supports background exection this method is called instead of WillTerminate
// when the user quits.
public override void DidEnterBackground (UIApplication application)
{
}
// This method is called as part of the transiton from background to active state.
public override void WillEnterForeground (UIApplication application)
{
}
// This method is called when the application is about to terminate. Save data, if needed.
public override void WillTerminate (UIApplication application)
{
}

public override void FinishedLaunching (UIApplication application)
{
InitializeLookback ();
}

void InitializeLookback ()
{
try {
LookbackSDK.Lookback.SetupWithAppToken("DCyaXMnEjH2bdtmjY");

LookbackSDK.Lookback lb = LookbackSDK.Lookback.lookback;
lb.ShakeToRecord = true;
lb.UserIdentifier = "sample user";

NSUserDefaults.StandardUserDefaults.SetBool (true, "com.thirdcog.lookback.preview.enabled");
NSUserDefaults.StandardUserDefaults.SetBool (true, "com.thirdcog.lookback.autosplit");

NSNotificationCenter.DefaultCenter.AddObserver ("com.thirdcog.lookback.notification.startedUploading", delegate (NSNotification n) {
NSUrl url = (NSUrl)n.UserInfo.ObjectForKey("com.thirdcog.lookback.notification.startedUploading.destinationURL".ToNSString());
UIPasteboard.General.Url = url;
} );

} catch {
Console.WriteLine ("Unable to initialize Lookback.");
}
}
}
}
6 changes: 6 additions & 0 deletions Lookback/samples/LookbackSample/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
Loading

0 comments on commit 9f4d983

Please sign in to comment.