In this third and last post (see Part 1 and Part 2) we look at pulling data into FileMaker Go using magnetic stripe readers. In principle this is very similar to the barcode method. A button in the FileMaker database calls an Open URL script step. This Open URL step calls the iOS app – in this case CardSwipe – and includes a callback function to the FileMaker database to run a script. The script then receives the input from the card.
"ccqfm://?" & GetAsURLEncoded ( "fmp://$/" & Get ( FileName ) & "?script=swipe¶m=" )
With the swipe action, instead of URL encoding each character, we tried using FileMaker’s native function – GetAsURLEncoded(), and this seemed to have no ill effects. Once the button is pressed, the iPhone (or iPad) switches over to CardSwipe, which is then ready for you to swipe the card.
Once the card is read by the iMag device, it immediately switches back to FileMaker and runs the “swipe” script, which reads the data. Each card that is read encodes its data differently, so extracting information is a matter of trial and error, and the text parsing process must be coded specifically to each card. Characters like “^” often separate key pieces of information. Credit Card numbers get picked up, so security becomes an issue once you read these, as storing the numbers is never recommended. Once again we split the scripts into three separate pieces to assist with any troubleshooting.
- A button calls the first script, which has one purpose: Perform script #2
- This script opens the iOS app using the Open URL script step, which has a callback to script #3
- The script that receives the data, using a script parameter in step #2
Issues that arose in this process centered around getting the proper URL. Luckily CardSwipe has great developer documentation. However, in the example, the one that referred to a local file (vs. one on the server) used the tilde sign instead of the $ sign, which looks for a file on the device, rather than an already open file. This sometimes caused issues with locating the right file, but when switched to the $ sign the callback worked seamlessly.
The iMag Pro hardware is attached to the iPhone through the USB connectors at the bottom. I found that this connection doesn’t remain firmly seated in the iPhone 4, but works well with an iPad. The iMag came with an adapter that is supposed to allow it to stick more firmly on the iPhone, but this didn’t work with the 4 model. If the card reader doesn’t separate from the iPhone or iPad, this method is perfect for quickly reading data from a card with a magnetic stripe.
Getting data quickly into an iPhone/iPad by scanning barcodes or reading cards with magnetic stripes makes your process mobile. This method can be used to not just for credit card actions, but any card that can be swiped, such as ID cards. Once the data is in your app, the next question is, “what’s next?” Some time back I wrote about building a real world FileMaker app using barcode scanning and Insert from URL to reach out to external databases and pull book information using just the barcode. You also could use this process to scan people for admission to events, read student information during school lunches, or attendees at a conference. Card readers might offer ways to get data about employees, build a POS device, and check drivers licenses or insurance card for medical offices. With a small investment (or in the case of pic2shop – no cost whatsoever) your business can be set up to read data using iPhones without having to type in data, speeding up the process and eliminating typos.
Thanks for your post as it is helpful and interesting. In your post, the Filemaker Go can get data by scanning barcodes or reading cards. My concern is whether I can retrieve records information from Filemaker Go in my native app using URL protocol.
Anders Monsen says
I wonder if you could call an FMP script that exported data, which your iOS app then could import. Calling a FileMaker database from the web or another iOS app with the fmp protocol should be possible, but the question then becomes what data are you looking to retrieve, and what would you do with this. Looking at the help notes (http://www.filemaker.com/help/12/fmp/html/sharing_data.16.7.html) I think you need to call a script to pull your data with some parameter to identify your records, and then you’d need to figure out how to get that data, possible from a csv file if that’s possible?
My native app (Objective-C coding) is a data collection software in Ipad. The fields of the table in FM Go is Id, Latitude, Longitude. And it has some points. Assume the app have this funtion that can load all the points information from FM Go using URL protocol. Your suggestion “I think you need to call a script to pull your data with some parameter to identify your records, and then you’d need to figure out how to get that data, possible from a csv file if that’s possible”. It worked for me. Just can I retrieve data from FM Go into a csv file that my app can read?
Anders Monsen says
Michael, I’m skating on theoretical ice here since I’m not an Objective-C coder, but I believe that there are functions that allow you to import and parse csv files. How to implement those in your app isn’t a question I can answer, but if your app calls the data from FileMaker, which exports the csv to a path that your app can access to import and then parse the data, that might be an option.
My article looked only at pulling data into FileMaker, so I’m not sure about sending data the other direction. I recommend you take a look at http://stackoverflow.com to see if there’s an Objective-C solution that can pull the data.
Hi Anders. I think that your suggestion should work: if your app calls the data from FileMaker, which exports the csv to a path that your app can access to import and then parse the data, that might be an option.
I will try. Thanks so much.
I am trying to use a similar solution as you lay out here however it keeps failing as it returns to the app and freezing up. This is Filemaker 16. have the recent changes to the platform made this model no longer relevant?
As a quick update to my inquiry apparently the extended privileges need to be set. Still working but at least I was able to receive data from the app!