Skip to content

Instantly share code, notes, and snippets.

@prashantvc
Last active January 13, 2016 11:14
Show Gist options
  • Save prashantvc/a5aa49fbfd16284ede82 to your computer and use it in GitHub Desktop.
Save prashantvc/a5aa49fbfd16284ede82 to your computer and use it in GitHub Desktop.
using System;
using UIKit;
using Foundation;
using ObjCRuntime;
using CoreGraphics;
using CoreLocation;
using CoreBluetooth;
namespace RetailApp.FootmarksBinding
{
// @protocol FMAccountDelegate <NSObject>
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface FMAccountDelegate
{
// @required -(void)loginSuccessful;
[Export ("loginSuccessful")]
[Abstract]
void LoginSuccessful ();
// @required -(void)loginUnsuccessful:(NSString *)error;
[Export ("loginUnsuccessful:")]
[Abstract]
void LoginUnsuccessful (string error);
}
// @interface FMAccount : NSObject
[BaseType (typeof(NSObject))]
interface FMAccount
{
// @property (assign, nonatomic) id<FMAccountDelegate> accountDelegate;
[Export ("accountDelegate", ArgumentSemantic.UnsafeUnretained)]
[NullAllowed]
NSObject WeakAccountDelegate { get; set; }
// @property (assign, nonatomic) id<FMAccountDelegate> accountDelegate;
[Wrap ("WeakAccountDelegate")]
FMAccountDelegate AccountDelegate { get; set; }
// +(instancetype)sharedInstance;
[Static, Export ("sharedInstance")]
FMAccount SharedInstance ();
// +(BOOL)enabled;
[Static, Export ("enabled")]
bool Enabled ();
// -(NSString *)getAppKey;
[Export ("getAppKey")]
string GetAppKey ();
// -(NSString *)getAppSecret;
[Export ("getAppSecret")]
string GetAppSecret ();
// -(void)setUserAccessToken:(NSString *)at;
[Export ("setUserAccessToken:")]
void SetUserAccessToken (string at);
// -(NSString *)getAccessToken;
[Export ("getAccessToken")]
string GetAccessToken ();
// -(void)loginToFootmarksServer:(NSString *)appKey andAppSecret:(NSString *)appSecret andUserId:(NSString *)userID;
[Export ("loginToFootmarksServer:andAppSecret:andUserId:")]
void LoginToFootmarksServer (string appKey, string appSecret, string userID);
// -(void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
[Export ("application:didFinishLaunchingWithOptions:")]
void Application (UIApplication application, [NullAllowed] NSDictionary launchOptions);
// -(void)sendFBDataToFootmarksServer:(NSMutableDictionary *)dict;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("sendFBDataToFootmarksServer:")]
void SendFBDataToFootmarksServer (NSMutableDictionary dict);
// -(void)useSmartProfilesInApplication:(UIApplication *)application withLaunchOptions:(NSDictionary *)launchOptions;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("useSmartProfilesInApplication:withLaunchOptions:")]
void UseSmartProfilesInApplication (UIApplication application, NSDictionary launchOptions);
}
// @interface FMBeacon : NSObject <CBPeripheralDelegate>
[BaseType (typeof(NSObject))]
interface FMBeacon : ICBPeripheralDelegate
{
// @property (nonatomic, strong) NSString * macAddress;
[Export ("macAddress", ArgumentSemantic.Retain)]
string MacAddress { get; set; }
// @property (nonatomic, strong) NSUUID * proximityUUID;
[Export ("proximityUUID", ArgumentSemantic.Retain)]
NSUuid ProximityUUID { get; set; }
// @property int txPowerMngmtConsole;
[Export ("txPowerMngmtConsole")]
int TxPowerMngmtConsole { get; set; }
// @property (nonatomic) NSInteger rssi;
[Export ("rssi")]
nint Rssi { get; set; }
// @property (nonatomic) CLLocationAccuracy accuracy;
[Export ("accuracy")]
double Accuracy { get; set; }
// @property (nonatomic) CLProximity proximity;
[Export ("proximity")]
CLProximity Proximity { get; set; }
// @property (nonatomic) CLProximity proximityiOSCalculation;
[Export ("proximityiOSCalculation")]
CLProximity ProximityiOSCalculation { get; set; }
// @property (nonatomic, strong) CBPeripheral * fmPeripheral;
[Export ("fmPeripheral", ArgumentSemantic.Retain)]
CBPeripheral FmPeripheral { get; set; }
// @property (retain, nonatomic) NSString * role;
[Export ("role", ArgumentSemantic.Retain)]
string Role { get; set; }
// @property (retain, nonatomic) NSString * name;
[Export ("name", ArgumentSemantic.Retain)]
string Name { get; set; }
// @property (retain, nonatomic) NSArray * tags;
[Export ("tags", ArgumentSemantic.Retain)]
NSObject [] Tags { get; set; }
// @property NSDate * dateOfLastImpression;
[Export ("dateOfLastImpression")]
NSDate DateOfLastImpression { get; set; }
// -(NSString *)stringForProximity:(CLProximity)prox;
[Export ("stringForProximity:")]
string StringForProximity (CLProximity prox);
}
// @interface FMBeaconRegion : CLBeaconRegion
[BaseType (typeof(CLBeaconRegion))]
interface FMBeaconRegion
{
}
// @protocol FMBeaconManagerDelegate <NSObject>
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface FMBeaconManagerDelegate
{
// @required -(void)bluetoothDidSwitchState:(CBCentralManagerState)state;
[Export ("bluetoothDidSwitchState:")]
[Abstract]
void BluetoothDidSwitchState (CBCentralManagerState state);
// @required -(void)locationServicesFailedWithError:(NSError *)error;
[Export ("locationServicesFailedWithError:")]
[Abstract]
void LocationServicesFailedWithError (NSError error);
// @optional -(void)bluetoothTurnedOff;
//[Availability (Deprecated = Platform.Mac_Version | Platform.Mac_Version)]
[Export ("bluetoothTurnedOff")]
void BluetoothTurnedOff ();
// @optional -(void)beaconManager:(FMBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(FMBeaconRegion *)region;
[Export ("beaconManager:didRangeBeacons:inRegion:")]
void DidRangeBeacons (FMBeaconManager manager, NSObject[] beacons, FMBeaconRegion region);
// @optional -(void)beaconManager:(FMBeaconManager *)manager rangingBeaconsDidFailForRegion:(FMBeaconRegion *)region withError:(NSError *)error;
[Export ("beaconManager:rangingBeaconsDidFailForRegion:withError:")]
void RangingBeaconsDidFailForRegion (FMBeaconManager manager, FMBeaconRegion region, NSError error);
// @optional -(void)beaconManager:(FMBeaconManager *)manager monitoringDidFailForRegion:(FMBeaconRegion *)region withError:(NSError *)error;
[Export ("beaconManager:monitoringDidFailForRegion:withError:")]
void MonitoringDidFailForRegion (FMBeaconManager manager, FMBeaconRegion region, NSError error);
// @optional -(void)beaconManager:(FMBeaconManager *)manager didEnterRegion:(FMBeaconRegion *)region;
[Export ("beaconManager:didEnterRegion:")]
void DidEnterRegion (FMBeaconManager manager, FMBeaconRegion region);
// @optional -(void)beaconManager:(FMBeaconManager *)manager didExitRegion:(FMBeaconRegion *)region;
[Export ("beaconManager:didExitRegion:")]
void DidExitRegion (FMBeaconManager manager, FMBeaconRegion region);
// @optional -(void)beaconManager:(FMBeaconManager *)manager didDetermineState:(CLRegionState)state forRegion:(FMBeaconRegion *)region;
[Export ("beaconManager:didDetermineState:forRegion:")]
void DidDetermineState (FMBeaconManager manager, CLRegionState state, FMBeaconRegion region);
// @optional -(void)beaconManagerDidStartScanningForBeacons:(FMBeaconManager *)manager;
[Export ("beaconManagerDidStartScanningForBeacons:")]
void BeaconManagerDidStartScanningForBeacons (FMBeaconManager manager);
// @optional -(void)beaconManagerDidStopScanningForBeacons:(FMBeaconManager *)manager;
[Export ("beaconManagerDidStopScanningForBeacons:")]
void BeaconManagerDidStopScanningForBeacons (FMBeaconManager manager);
}
// @interface FMBeaconManager : NSObject <CBCentralManagerDelegate, CBPeripheralManagerDelegate, CLLocationManagerDelegate>
[BaseType (typeof(NSObject))]
interface FMBeaconManager:ICBCentralManagerDelegate,ICBPeripheralManagerDelegate,ICLLocationManagerDelegate
{
// @property (nonatomic, weak) id<FMBeaconManagerDelegate> delegate;
[Export ("delegate", ArgumentSemantic.Weak)]
[NullAllowed]
NSObject WeakDelegate { get; set; }
// @property (nonatomic, weak) id<FMBeaconManagerDelegate> delegate;
[Wrap ("WeakDelegate")]
FMBeaconManagerDelegate Delegate { get; set; }
// @property CBCentralManagerState curBluetoothState;
[Export ("curBluetoothState")]
CBCentralManagerState CurBluetoothState { get; set; }
// +(instancetype)sharedInstance;
[Static, Export ("sharedInstance")]
FMBeaconManager SharedInstance ();
// -(NSArray *)getBeaconsInRange;
[Export ("getBeaconsInRange")]
NSObject [] GetBeaconsInRange ();
// -(void)startScanningForFMBeaconsWithError:(NSError **)error;
[Export ("startScanningForFMBeaconsWithError:")]
void StartScanningForFMBeaconsWithError (out NSError error);
// -(void)stopScanningForFMBeaconsWithError:(NSError **)error;
[Export ("stopScanningForFMBeaconsWithError:")]
void StopScanningForFMBeaconsWithError (out NSError error);
// -(BOOL)isScanningForBeacons;
[Export ("isScanningForBeacons")]
bool IsScanningForBeacons ();
// -(void)customerCameWithinRangeOfBeacon:(FMBeacon *)beacon;
[Export ("customerCameWithinRangeOfBeacon:")]
void CustomerCameWithinRangeOfBeacon (FMBeacon beacon);
// -(void)startScanningForFMBeacons;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("startScanningForFMBeacons")]
void StartScanningForFMBeacons ();
// -(void)stopScanningForFMBeacons;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("stopScanningForFMBeacons")]
void StopScanningForFMBeacons ();
}
// @interface FMExperience : NSObject
[BaseType (typeof(NSObject))]
interface FMExperience
{
// -(id)initExperienceWithName:(NSString *)name type:(FMExperienceType)type action:(FMExperienceAction)action customDetails:(NSString *)customDetails expTitle:(NSString *)expTitle expDescription:(NSString *)expDes notificationTitle:(NSString *)notifTitle notificationDescription:(NSString *)notifDes showNotification:(BOOL)show customActions:(NSArray *)customArray expContent:(FMExpContent *)content;
[Export ("initExperienceWithName:type:action:customDetails:expTitle:expDescription:notificationTitle:notificationDescription:showNotification:customActions:expContent:")]
IntPtr Constructor (string name, FMExperienceType type, FMExperienceAction action, string customDetails, string expTitle, string expDes, string notifTitle, string notifDes, bool show, NSObject[] customArray, FMExpContent content);
// -(id)initWithJSONDict:(NSDictionary *)dict;
[Export ("initWithJSONDict:")]
IntPtr Constructor (NSDictionary dict);
// @property (retain, nonatomic) NSString * expId;
[Export ("expId", ArgumentSemantic.Retain)]
string ExpId { get; set; }
// @property (retain, nonatomic) NSString * name;
[Export ("name", ArgumentSemantic.Retain)]
string Name { get; set; }
// @property (readonly, nonatomic) FMExperienceType type;
[Export ("type")]
FMExperienceType Type { get; }
// @property FMExperienceAction action;
[Export ("action")]
FMExperienceAction Action { get; set; }
// @property (retain, nonatomic) NSString * customDetails;
[Export ("customDetails", ArgumentSemantic.Retain)]
string CustomDetails { get; set; }
// @property (retain, nonatomic) NSString * expTitle;
[Export ("expTitle", ArgumentSemantic.Retain)]
string ExpTitle { get; set; }
// @property (retain, nonatomic) NSString * expDescription;
[Export ("expDescription", ArgumentSemantic.Retain)]
string ExpDescription { get; set; }
// @property (retain, nonatomic) NSString * notificationTitle;
[Export ("notificationTitle", ArgumentSemantic.Retain)]
string NotificationTitle { get; set; }
// @property (retain, nonatomic) NSString * notificationDescription;
[Export ("notificationDescription", ArgumentSemantic.Retain)]
string NotificationDescription { get; set; }
// @property (retain, nonatomic) NSArray * customActions;
[Export ("customActions", ArgumentSemantic.Retain)]
NSObject [] CustomActions { get; set; }
// @property BOOL showNotif;
[Export ("showNotif")]
bool ShowNotif { get; set; }
// @property NSMutableDictionary * content;
[Export ("content")]
NSMutableDictionary Content { get; set; }
// -(void)sendConvertedExperienceWithType:(FMConvertedAction)action valueType:(FMConvertedValueType)vType andValue:(float)value;
[Export ("sendConvertedExperienceWithType:valueType:andValue:")]
void SendConvertedExperienceWithType (FMExperienceAction action, FMExperienceType vType, float value);
// -(void)sendCustomConvertedExperienceWithType:(FMConvertedAction)action andCustomActionName:(NSString *)customAction valueType:(FMConvertedValueType)vType andCustomValueName:(NSString *)customValName andValue:(float)value;
[Export ("sendCustomConvertedExperienceWithType:andCustomActionName:valueType:andCustomValueName:andValue:")]
void SendCustomConvertedExperienceWithType (FMExperienceAction action, string customAction, FMExperienceType vType, string customValName, float value);
// -(void)sendExperienceToUser:(NSString *)username andDevice:(NSString *)deviceId;
[Export ("sendExperienceToUser:andDevice:")]
void SendExperienceToUser (string username, string deviceId);
// -(NSMutableDictionary *)returnJsonDictForAttributes;
[Export ("returnJsonDictForAttributes")]
NSMutableDictionary ReturnJsonDictForAttributes ();
// -(NSString *)alertTitle;
[Export ("alertTitle")]
string AlertTitle ();
}
// @protocol FMExperienceManagerDelegate <NSObject>
[Protocol, Model]
[BaseType (typeof(NSObject))]
interface FMExperienceManagerDelegate
{
// @required -(void)didCompleteExperiences:(NSArray *)experiences;
[Export ("didCompleteExperiences:")]
[Abstract]
void DidCompleteExperiences (NSObject[] experiences);
}
// @interface FMExperienceManager : NSObject
[BaseType (typeof(NSObject))]
interface FMExperienceManager
{
// @property (nonatomic, weak) id<FMExperienceManagerDelegate> delegate;
[Export ("delegate", ArgumentSemantic.Weak)]
[NullAllowed]
NSObject WeakDelegate { get; set; }
// @property (nonatomic, weak) id<FMExperienceManagerDelegate> delegate;
[Wrap ("WeakDelegate")]
FMExperienceManagerDelegate Delegate { get; set; }
// +(id)sharedInstance;
[Static, Export ("sharedInstance")]
NSObject SharedInstance ();
// +(FMExperience *)returnExperienceOfType:(FMExperienceType)type fromExpArray:(NSArray *)arr;
[Static, Export ("returnExperienceOfType:fromExpArray:")]
FMExperience ReturnExperienceOfType (FMExperienceType type, NSObject[] arr);
// -(FMExperience *)returnCorrectExp:(NSDictionary *)d;
[Export ("returnCorrectExp:")]
FMExperience ReturnCorrectExp (NSDictionary d);
}
// @interface FMVideoExp : FMExperience
[BaseType (typeof(FMExperience))]
interface FMVideoExp
{
// @property FMDisplayType displayType;
[Export ("displayType")]
FMDisplayType DisplayType { get; set; }
// @property FMContentProvider contentProvider;
[Export ("contentProvider")]
FMContentProvider ContentProvider { get; set; }
// @property (retain, nonatomic) NSString * vidURL;
[Export ("vidURL", ArgumentSemantic.Retain)]
string VidURL { get; set; }
// -(NSString *)getYoutubeVideoID:(NSString *)url;
[Export ("getYoutubeVideoID:")]
string GetYoutubeVideoID (string url);
// -(void)playYoutubeVideoUsingVC:(UIViewController *)viewCon withFinishedSelector:(SEL)selFinished;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("playYoutubeVideoUsingVC:withFinishedSelector:")]
void PlayYoutubeVideoUsingVC (UIViewController viewCon, Selector selFinished);
}
// @interface FMImageExp : FMExperience
[BaseType (typeof(FMExperience))]
interface FMImageExp
{
// @property (retain, nonatomic) NSString * imgURL;
[Export ("imgURL", ArgumentSemantic.Retain)]
string ImgURL { get; set; }
// -(void)presentPicInUIImageView:(UIImageView *)imgView;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("presentPicInUIImageView:")]
void PresentPicInUIImageView (UIImageView imgView);
}
// @interface FMAlertExp : FMExperience
[BaseType (typeof(FMExperience))]
interface FMAlertExp
{
// -(void)showAlert;
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[Export ("showAlert")]
void ShowAlert ();
}
// @interface FMHTMLExp : FMExperience
[BaseType (typeof(FMExperience))]
interface FMHTMLExp
{
// @property (retain, nonatomic) NSString * html;
[Export ("html", ArgumentSemantic.Retain)]
string Html { get; set; }
}
// @interface FMUrlExp : FMExperience
[BaseType (typeof(FMExperience))]
interface FMUrlExp
{
// @property (retain, nonatomic) NSString * url;
[Export ("url", ArgumentSemantic.Retain)]
string Url { get; set; }
}
// @interface FMCustomExp : FMExperience
[BaseType (typeof(FMExperience))]
interface FMCustomExp
{
// @property (retain, nonatomic) NSString * text;
[Export ("text", ArgumentSemantic.Retain)]
string Text { get; set; }
}
// @interface FMExpContent : NSObject
[BaseType (typeof(NSObject))]
interface FMExpContent
{
// -(id)initImageContentWithUrl:(NSString *)url;
[Export ("initImageContentWithUrl:")]
IntPtr Constructor (string url);
// -(id)initVideoContentWithProvider:(FMContentProvider)provider displayType:(FMDisplayType)displayType videoUrl:(NSString *)url;
[Export ("initVideoContentWithProvider:displayType:videoUrl:")]
IntPtr Constructor (FMContentProvider provider, FMDisplayType displayType, string url);
// // -(id)initUrlContentWithUrl:(NSString *)url;
// [Export ("initUrlContentWithUrl:")]
// IntPtr Constructor (string url);
//
// // -(id)initHtmlContentWithText:(NSString *)text;
// [Export ("initHtmlContentWithText:")]
// IntPtr Constructor (string htmlText);
//
// // -(id)initCustomContentWithText:(NSString *)text;
// [Export ("initCustomContentWithText:")]
// IntPtr Constructor (string customText);
}
// @interface FMRestApi : NSObject <NSURLConnectionDelegate>
//[Availability (Deprecated = Platform.iOS_Version | Platform.Mac_Version)]
[BaseType (typeof(NSObject))]
interface FMRestApi : INSUrlConnectionDelegate
{
// @property NSInteger httpStatusCode;
[Export ("httpStatusCode")]
nint HttpStatusCode { get; set; }
// -(void)postWithUrl:(NSString *)urlStr headers:(NSDictionary *)headers formData:(NSData *)postData timeout:(NSTimeInterval)timeout withCompletion:(FMRestCompletion)completion;
[Export ("postWithUrl:headers:formData:timeout:withCompletion:")]
void PostWithUrl (string urlStr, NSDictionary headers, NSData postData, double timeout, Action<NSObject, NSError> completion);
}
}
using Foundation;
using UIKit;
using RetailApp.FootmarksBinding;
namespace RetailApp
{
// 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 class AppDelegate : UIApplicationDelegate
{
// class-level declarations
public override UIWindow Window {
get;
set;
}
private FMBeaconManager _fmAppBeaconManager;
public FMBeaconManager SharedBeaconManager {
get {
if (_fmAppBeaconManager == null) {
_fmAppBeaconManager = FMBeaconManager.SharedInstance ();
_fmAppBeaconManager.Delegate = new CommonBeaconManager ();
}
return _fmAppBeaconManager;
}
}
public class MyAccountDelegate : FMAccountDelegate
{
public override void LoginSuccessful ()
{
SharedBeaconManager.StartScanningForFMBeacons ();
}
public override void LoginUnsuccessful (string error)
{
System.Console.WriteLine ("Login error: {0}", error);
}
}
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
// Code to start the Xamarin Test Cloud Agent
var account = FMAccount.SharedInstance ();
account.Application (application, launchOptions);
account.AccountDelegate = new MyAccountDelegate ();
//TODO - Update the code
account.LoginToFootmarksServer ("Key", "secret", "Username");
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment