joe.log

notes on computing and more

Access the Windows Phone Camera Button from a C# Windows Universal Project

It is possible to reference the hardware buttons of a Windows Phone device, in this case the camera button, from a Windows Universal project by using the following:

#if WINDOWS_PHONE_APP
           Windows.Phone.UI.Input.HardwareButtons.CameraHalfPressed += HardwareButtons_CameraHalfPressed;
           Windows.Phone.UI.Input.HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
#endif

Facebook Login on Windows Phone 8.1 / Windows Universal

On the Facebook Developers site there is now a section that explains how to do Login with Facebook on a Windows Phone App (https://developers.facebook.com/docs/facebook-login/login-for-windows-phone). The provided info is good but it required the user to have the Facebook app installed. I suspect a high percentage of the users who might use a ‘Login with Facebook’ option will have the Facebook app installed on their devices but nevertheless I was looking for a solution that would promt the user to login to Facebook throught a web site and not the app. Here is how I did it for my Windows Phone 8.1, Windows Universal app:

  1. Be sure to create the appropriate Facebook app first on: https://developers.facebook.com/apps Select as platform Windows and introduce your Windows Phone Store ID.
    If the app you are currently developing is not on the Windows Phone Store, you will have to go to your Windows Phone Project’s Package.appxmanifest file, go to the Packaging tap and use the Package name (without the dashes) as the Windows Phone Store ID. IMPORTANT: Remember to change it once you upload the app to the store!   
  2. Next we have to set up the URI association to handle the redirect from the Facebook authentication site. Go to your Windows Phone Project Package.appxmanifest  go to the Declarations tab, add a Protocol declaration. And in the Name field put: msft-YOUR_WINDOWS_PHONE_STORE_ID
  3. Now we have to build the authentication URL and redirect the user there. The code is the following one and you can put it on the function of the event that is fired when the user taps a Login with Facebook button, for example.
  4. When the user finishes with the Facebook Login page, your app will open again. The OnActivated method on App.xaml.cs will be called. This is the code you can use to handle the response

I hope this info is useful to you to quickly implement Facebook Login on your Windows Phone app! :)

Bluetooth LE (4.0) USB dongle that works to test Bluetooth LE in the iOS Simulator

image

If you’re looking for a Bluetooth Low Energy 4.0 USB Dongle that is compatible with iOS 6 simulator the Cirago Bluetooth 4.0 USB Mini Adapter (BTA8000) is a safe choice. 

Before attaching the dongle to the computer, you will need to run the following command on the terminal in order for the iOS simulator to be able to use the Bluetooth dongle. 

sudo nvram bluetoothHostControllerSwitchBehavior=“never”

More info about getting Bluetooth Low Energy 4.0 to work in the iOS simulator as well as an explanation about the previous command can be found on Apple’s Technical Note TN2295

Belkin Mini Bluetooth V4.0 USB Adapter (F8T065) on MAC OS X

image

I recently purchased a Bluetooth Low Energy (4.0) USB dongle adapter for a Mac Book Pro. Unfortunately this adapter doesn’t work out of the box on MAC OS, and Belkin doesn’t provide drivers for MAC OS either.

But somebody found a way to make unsupported Bluetooth Low Energy dongles work on MAC OS X. You can see the full details in this blog post. It explains all the steps needed for any unsupported dongle, I describe bellow the specific steps for the Belkin Mini Bluetooth V4.0 USB Adapter, model F8T065.

  1. Click on Finder. Then on the menu bar go to Go –> Go to Folder…
  2. Locate a file named: IOBluetoothFamily.kext
  3. Copy this file to another location, like the Desktop.
  4. Ctrl+click on IOBluetoothFamily.kext and click on Show Package Contents image
  5. Navigate to Contents –> PlugIns
  6. You will find another .kext file named: BroadcomBluetoothHCIControllerUSBTransport.kext
  7. Again Ctrl+click and click on Show Package Contents
  8. Navigate to the Contents folder and you will see a file named Info.plist
  9. Open the Info.plist file with your favourite text editor like Text Edit or Sublime Text
  10. Scroll down the content of the file until you see: <key>Microsoft Bluetooth 2.0 USB Dongle</key>
  11. Add a new entry by copying and pasting the text starting in line 14 up to the end, just after the Microsoft Bluetooth 2.0 USB Dongle entry.
  1. Save the file and download an application called Kext Utility. You can download it here
  2. Once downloaded, start Kext Utility and wait until it complete all the operations it does when it starts. Then drag the edited IOBluetoothFamily.kext to Kext Utility.
  3. Once it’s done with the installation, just restart the computer and next time MAC OS X boots it should recognise the Belkin Bluetooth 4.0 dongle.

I hope these indications are helpful. You can now enjoy the benefits of Bluetooth Low Energy on your MAC :)  

Hello World

It wouldn’t be appropriate to start this blog without  a “Hello World”.

It’s a simple but yet so powerful tradition in software development. It introduces you to a new programming language, and from the first compilation/execution you’re already caught by the magic of software and you realize it’s endless possibilities.

Thanks for stopping by!

Joe Fernandez (@fdezjose)