NimbleKit - fast iOS app development

Reading QRCode in NimbleKit

Ask questions and share your skills here

Re: Reading QRCode in NimbleKit

Postby Swalif » Sun Feb 19, 2012 8:19 pm

Any news of QRCode Reader sample?

I have the same issue and not working in device.

Swalif.
Swalif
 
Posts: 3
Joined: Tue Jan 24, 2012 9:50 am

Re: Reading QRCode in NimbleKit

Postby jazzbass » Mon Feb 20, 2012 1:37 am

1) Install the attachment file if you have already installed Nimblekit 1.9.9
2) Create a new nimblekit project.
3) Method 1
From project explorer choose Supporting Files > NKit.xconfig
find -l Nimblekit and paste the below line to near it.
Code: Select all
 -weak_framework QuartzCore -weak_framework CoreVideo -weak_framework CoreMedia -l NKQR -l iconv 

then save file.
Method 2
if you are not lazy, do not paste above and goto Targets > Build Phases > Link Binary with Libraries.
Add QuartzCore, CoreVideo, CoreMedia and libiconv.dylib and change Required attribute to optional.
then "Add other" choose /Library/Frameworks/libNKQR.a file.

4 ) paste this code to your main.html
Code: Select all
<html>
    <head>
        <meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript" src="NKit.js"></script>
    </head>
    <body>
        <script>
            NKRegisterClass("NKQRObject");
            var key = ""; // Enter Your Licence Key here
            var page = "main.html"; // enter current page name
           
            function result(barcode) //Receives Barcode Result Data from Objective C
            {
                document.getElementById('barcoderesult').innerHTML = "Barcode: " + barcode;
                // use barcode variable after read action
            }
           
           
            function openreader()
            {
                CallNKitAction("scanButtonTapped?className=NKQRObject&page="+page+"&key="+key);
            }
            </script>
       
        <button onClick=openreader()>Open Barcode Reader</button>
       
        <div id=barcoderesult></div>
    </body>
</html>


5) Run the project and do not forget entering your nimblekit serial in appdelegate.m
6) For Barcode Reader license contact me.

if it does not run properly, then check your settings, version etc. There might be bugs with tabs or navigation controllers or other extreme cases. There is not any current bug for basic running for sure.
Attachments
NK Barcode Reader.pkg.zip
(1.25 MiB) Downloaded 63 times
User avatar
jazzbass
 
Posts: 139
Joined: Sun Jun 27, 2010 9:01 pm

Re: Reading QRCode in NimbleKit

Postby rouillip » Mon Feb 20, 2012 9:55 am

Thanks for your advices
But i don't suceed to have it working after a lot of tries
I send you my project may be you could have it working !
Anyway thank you for all your efforts
Attachments
qrcode.zip
(1.09 MiB) Downloaded 35 times
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: Reading QRCode in NimbleKit

Postby jazzbass » Mon Feb 20, 2012 10:22 am

Your nimblekit seems much older version. It includes, name before app delegate, build folder, xib file and frameworks group. New version does not have these. Or maybe your xcode older, I do not know.
Barcode Scanner works projects only created with 1.9.9.

For your sepcific case do Targets > Build Phases > Link Binary with Libraries. add
AVFoundation.framework CoreGraphics.framework CoreMedia.framework CoreVideo.framework QuartzCore.framework libiconv.dylib Foundation.framework UIKit.framework and then "Add other" choose /Library/Frameworks/libNKQR.a file.
This way it must be work.

Edit: Your Xcode seems older, or you save project supporting xocde 3.1 compatible format.
I edited your project and it works.
Attachments
qrcode.zip
(31.93 KiB) Downloaded 41 times
User avatar
jazzbass
 
Posts: 139
Joined: Sun Jun 27, 2010 9:01 pm

Re: Reading QRCode in NimbleKit

Postby kkiphone » Tue Feb 21, 2012 3:20 am

hi jazzbass,
how can i get the Barcode Reader license?
kkiphone
 
Posts: 1
Joined: Mon Feb 20, 2012 9:12 am

Re: Reading QRCode in NimbleKit

Postby rouillip » Tue Feb 21, 2012 9:29 am

I suppose the problem comes because i use XCode 3.2.5
I have not the fonctions :

For your sepcific case do Targets > Build Phases > Link Binary with Libraries. add

I will update my XCode and try again
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: Reading QRCode in NimbleKit

Postby rouillip » Tue Feb 21, 2012 6:27 pm

I switch to XCode 4, and i made a lot of progress !
Now i get the button "Open Barcode reader" and on click its open the scanner !
But i have difficulies to scan a QRcode, some time it will and display the content of the QRcode, and sometime not. In this case its stay blocked on the screen with the alert requesting the licence. I have to delete the application and load it again.
Are all the QRcode allowed to be scanned ?
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: Reading QRCode in NimbleKit

Postby jazzbass » Tue Feb 21, 2012 6:53 pm

can you send the example of blocking qr code then I will check.
On testing, if you press "open barcode reader" while you put cam on qr code, it reads qr so fast and first & second licence alerts may conflict.
User avatar
jazzbass
 
Posts: 139
Joined: Sun Jun 27, 2010 9:01 pm

Re: Reading QRCode in NimbleKit

Postby rouillip » Tue Feb 21, 2012 8:05 pm

Its seems better now, i think i have to center the qrcode in thre screen and not to try to have it over the modal alert window !
I would like now to use the readed bare code to open a new page.
So i define a qrcode as : http://www.google.fr and i add in the result function :

window.location.href = barecode;

but this doesn't works should i use an NK function

NKMoveToPageAnimated('mypage.html','fade')

to open for instance a local page?
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: Reading QRCode in NimbleKit

Postby jazzbass » Tue Feb 21, 2012 8:42 pm

using nk functions are better to go to another page. window.location.href broke viewcontroller.
For opening remote page it is better to use NKOpenURLInSafari or using ChildBrowser viewtopic.php?f=13&t=3451&p=17732&hilit=childbrowser#p17710
User avatar
jazzbass
 
Posts: 139
Joined: Sun Jun 27, 2010 9:01 pm

PreviousNext

Return to How To...

Who is online

Users browsing this forum: Bing [Bot] and 1 guest