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

Commit

Permalink
1.2.1 fixes and ios binding lib
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Jul 24, 2015
1 parent f5efded commit ef43db0
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 153 deletions.
20 changes: 16 additions & 4 deletions Estimotes.Droid/BeaconManagerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class BeaconManagerImpl : AbstractBeaconManagerImpl {

public BeaconManagerImpl() {
this.beaconManager = new BeaconManager(Application.Context);
//this.beaconManager.Nearable += (sender, args) => {};
//this.beaconManager.Eddystone += (sender, args) => { };

this.beaconManager.EnteredRegion += (sender, args) => {
var region = this.FromNative(args.Region);
this.OnRegionStatusChanged(region, true);
Expand All @@ -36,11 +39,14 @@ public override async Task<BeaconInitStatus> Initialize() {
if (this.isConnected)
return BeaconInitStatus.Success;

if (this.beaconManager.IsBluetoothEnabled)
if (!this.beaconManager.HasBluetooth)
return BeaconInitStatus.BluetoothMissing;

if (!this.beaconManager.IsBluetoothEnabled)
return BeaconInitStatus.BluetoothOff;

if (!this.beaconManager.CheckPermissionsAndService())
return BeaconInitStatus.PermissionDenied; // TODO: more!
return BeaconInitStatus.PermissionDenied;

var tcs = new TaskCompletionSource<BeaconInitStatus>();
lock (this.syncLock) {
Expand All @@ -55,7 +61,13 @@ public override async Task<BeaconInitStatus> Initialize() {
this.beaconManager.Connect(ready);
}

return await tcs.Task;
var status = await tcs.Task;
// restore monitored beacons
//if (status == BeaconInitStatus.Success)
// foreach (var region in this.MonitoringRegions)
// this.StartMonitoringNative(region);

return status;
}


Expand Down
66 changes: 66 additions & 0 deletions Estimotes.iOS.Binding/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Drawing;

using ObjCRuntime;
using Foundation;
using UIKit;

namespace Estimotes.iOS.Binding {
// The first step to creating a binding is to add your native library ("libNativeLibrary.a")
// to the project by right-clicking (or Control-clicking) the folder containing this source
// file and clicking "Add files..." and then simply select the native library (or libraries)
// that you want to bind.
//
// When you do that, you'll notice that MonoDevelop generates a code-behind file for each
// native library which will contain a [LinkWith] attribute. VisualStudio auto-detects the
// architectures that the native library supports and fills in that information for you,
// however, it cannot auto-detect any Frameworks or other system libraries that the
// native library may depend on, so you'll need to fill in that information yourself.
//
// Once you've done that, you're ready to move on to binding the API...
//
//
// Here is where you'd define your API definition for the native Objective-C library.
//
// For example, to bind the following Objective-C class:
//
// @interface Widget : NSObject {
// }
//
// The C# binding would look like this:
//
// [BaseType (typeof (NSObject))]
// interface Widget {
// }
//
// To bind Objective-C properties, such as:
//
// @property (nonatomic, readwrite, assign) CGPoint center;
//
// You would add a property definition in the C# interface like so:
//
// [Export ("center")]
// CGPoint Center { get; set; }
//
// To bind an Objective-C method, such as:
//
// -(void) doSomething:(NSObject *)object atIndex:(NSInteger)index;
//
// You would add a method definition to the C# interface like so:
//
// [Export ("doSomething:atIndex:")]
// void DoSomething (NSObject object, int index);
//
// Objective-C "constructors" such as:
//
// -(id)initWithElmo:(ElmoMuppet *)elmo;
//
// Can be bound as:
//
// [Export ("initWithElmo:")]
// IntPtr Constructor (ElmoMuppet elmo);
//
// For more information, see http://docs.xamarin.com/ios/advanced_topics/binding_objective-c_types
//
}

50 changes: 50 additions & 0 deletions Estimotes.iOS.Binding/Estimotes.iOS.Binding.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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>
<ProjectTypeGuids>{8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{1DC35113-BF49-4B3C-BC9B-DF55A421A9E2}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Estimotes.iOS.Binding</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>Estimotes.iOS.Binding</AssemblyName>
</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="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
</Project>
34 changes: 34 additions & 0 deletions Estimotes.iOS.Binding/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Reflection;
using System.Runtime.CompilerServices;

using Foundation;

// This attribute allows you to mark your assemblies as “safe to link”.
// When the attribute is present, the linker—if enabled—will process the assembly
// even if you’re using the “Link SDK assemblies only” option, which is the default for device builds.

[assembly: LinkerSafe]

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("Estimotes.iOS.Binding")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Estimotes.iOS.Binding")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
5 changes: 5 additions & 0 deletions Estimotes.iOS.Binding/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System;

namespace Estimotes.iOS.Binding {
}

Loading

0 comments on commit ef43db0

Please sign in to comment.