dermotos / Bump-API-Monotouch-Binding

Monotouch Binding for Bump API v3.0
2 stars 1 forks source link

Missing sample app #1

Open MichaelB14 opened 11 years ago

MichaelB14 commented 11 years ago

Your solution has a sample project in it that appears to be missing in github. Can you upload the sample? Trying to figure out the correct mtouch arguments.

Thanks

dermotos commented 11 years ago

I've written a working binding using v3.0, ill upload it later today.

MichaelB14 commented 11 years ago

Awesome. Thanks

Sent mysterously through thin air!

On Jul 26, 2012, at 8:13 PM, dermotos reply@reply.github.com wrote:

I've written a working binding using v3.0, ill upload it later today.


Reply to this email directly or view it on GitHub: https://github.com/dermotos/Bump-API-Monotouch-Binding/issues/1#issuecomment-7294427

dermotos commented 11 years ago

Here you go : https://dl.dropbox.com/u/8617393/Bump3Binding.zip (it's still uploading to dropbox, so maybe give it another 10 minutes) I actually encountered an issue which is documented here: https://groups.google.com/forum/?fromgroups#!topic/google-admob-ads-sdk/h99slwzq12Y

and a workaround documented here: https://groups.google.com/forum/?fromgroups#!topic/bump-api/WZPAstG-OGM

It occurred when using it in a project with another library, possibly FlurryAnalytics, I cant remember. Eitherway, thats what the .modified versions of the .a files are. The compiled DLL is in there, so you should just be able to reference that in your project. Source is also there in case you need to make changes to the binding.

This is how it's used:

BumpClient.Configure("YOUR_API_KEY",State.LocalUser.ID);

BumpClient.SharedClient.SetConnectionStateChangedBlock(delegate(boolconnectedToBumpServer) {

//Code here fired when connection change occurs

BumpConnected = connectedToBumpServer;

//etc...

} );

BumpClient.SharedClient.Bumpable = true;

Hope that helps.

On Fri, Jul 27, 2012 at 10:28 AM, Michael < reply@reply.github.com

wrote:

Awesome. Thanks

Sent mysterously through thin air!

On Jul 26, 2012, at 8:13 PM, dermotos reply@reply.github.com wrote:

I've written a working binding using v3.0, ill upload it later today.


Reply to this email directly or view it on GitHub:

https://github.com/dermotos/Bump-API-Monotouch-Binding/issues/1#issuecomment-7294427


Reply to this email directly or view it on GitHub:

https://github.com/dermotos/Bump-API-Monotouch-Binding/issues/1#issuecomment-7294652

ghost commented 11 years ago

hi, first off thanks for sharing this binding project!

I have no real obj-c knowledge and I am a bit confused by the use of the exported 'bumpable' property. Is this a class-property (you use the static keyword next to the Export) or an instance property (you use BumpClient.SharedClient.Bumpable = true; in your last comment)?

Either way I export it, I end up with a runtime error: "unrecognized selector sent to class .." when trying to (read or write) access 'bumpable'.

any help would be appreciated!

dermotos commented 11 years ago

Here's how I use the library (sorry about lack of indentation)

In my App delegate, I have this:

public bool BumpConnected {get;set;}

public delegate void BumpConnectivityChanged(bool connected); public event BumpConnectivityChanged OnBumpConnectivityChanged;

private void InitializeBump() {

BumpClient.Configure(Constants.BumpApiKey,State.LocalUser.ID); BumpClient.SharedClient.SetConnectionStateChangedBlock(delegate(boolconnectedToBumpServer) {

BumpConnected = connectedToBumpServer;

if(OnBumpConnectivityChanged!= null) OnBumpConnectivityChanged(connectedToBumpServer);

} );

BumpClient.SharedClient.Bumpable = false;

}

I have bump set to false, as I dont want it reacting to bump/motion events until I show my custom Bump UI.

My bump UI is in another view, that I add to my KeyWindow (UIApplication.SharedApplication.KeyWindow) This ensures it is "always on top" as the KeyWindow the the window of your app, all over views are within it.

In my custom UI view, I set my bump event blocks like so:

BumpClient.SharedClient.SetBumpEventBlock (delegate(BumpEvent evt) {

Console.WriteLine("A bump occurred");

});

The BumpEvent evt field contains info regarding the other bumper, if the bump was successful etc.. Generally speaking, you will want to use the MatchBlock to make a connection to the other party. Once you have your connection, you can send your data over the open connection, and it will raise whatever delegate you've set as your DataReceived() block.

Easiest way to create an NSData to pass to the BumpClient.SharedClient.SendData() method is by using

NSData sendingBytes = NSData.FromArray (yourSerializedObjectAsAByteArray); (ensure you include system.linq in your using statements at the top of the class)

The easiest way to convert NSData into a byte array would be to use the Marshal.Copy method:

"data" being the NSData you receive in the DataReceived() block of the bump.

byte[] dataReceived = new byte[data.Length];

System.Runtime.InteropServices.Marshal.Copy (data.Bytes, dataReceived, 0, Convert.ToInt32 (data.Length)); Now dataReceived contains all the bytes that were sent.

While im talking about this stuff, I found its best to avoid binary serialization, as it can get messy when you create different versions of the app, etc.. I currently use NewtonSoft's JSON.NET implementation as my data is mostly text. Its much more efficient. If your sending audio, images video etc... you should be able to get the byte stream directly from disk and send it through.

Hope this helps.

On Fri, Aug 3, 2012 at 12:45 AM, frinx < reply@reply.github.com

wrote:

hi, first off thanks for sharing this binding project!

I have no real obj-c knowledge and I am a bit confused by the use of the exported 'bumpable' property. Is this a class-property (you use the static keyword next to the Export) or an instance property (you use BumpClient.SharedClient.Bumpable = true; in your last comment)?

Either way I export it, I end up with a runtime error: "unrecognized selector sent to class .." when trying to (read or write) access 'bumpable'.

any help would be appreciated!


Reply to this email directly or view it on GitHub:

https://github.com/dermotos/Bump-API-Monotouch-Binding/issues/1#issuecomment-7457253

ghost commented 11 years ago

Thank you for clearing things up! This explained the intended use of the Bumpable flag, but it seems to be a field of the SharedClient which is an instance of BumpClient, right? I find the "Static" keyword in the export/binding in the Apidescription still a bit confusing, but I havent tested it yet the way you suggest.

Thanks also for mentioning the NSData / byte[] conversion solution! That will probably be useful to others as well.