MQr

MQr Framework 에 대한 필수 API 를 정의

Qr API

Qr code 관련 기능을 제공한다.

Qr code 스캔

M.qr.scan(setting)

Changed in version 2.1.5.9.

Arguments
  • setting (Object) – 스캔을 위한 설정 정보

  • setting.flash (Bool) – 플래시 사용 여부

  • setting.fadeToggle (String) – 버튼 메뉴 애니메이션

  • setting.orientation (String) – 화면 오리엔테이션 ( Orientation Type )

  • setting.page (String) – 커스텀 페이지 호출

  • setting.captureScale (Object) – 캡쳐 범위 scale( {width:Float, height:Float} ), default = 1.0[max 1.0]

  • setting.filterType (String) – filterType (Symbol)

  • setting.callback (Function) – 스캔 결과 콜백 함수

  • setting.useGuideLine (Bool) – 가이드 라인 표시 여부 (default : false)

M.qr.callback(result)
Arguments
  • result (Object) – 실행 결과

  • result.status (String) – 실행 결과 코드 ( SUCCESS: 성공 코드, FAIL: 실패 코드 )

  • result.error (String) – 오류 시 메세지

  • result.format (String) – 스캔한 결과의 포맷

  • result.text (String) – 스캔한 결과의 텍스트

  • Qr code 를 스캔한다.

Surrogate Keys: 위 옵션키들과 같은 하위 버전 호환을 위한 대체 옵션 값들
  • onscan = callback

  • orient = orientation

  • orientationType = orientation

  • menuanimation = fadetoggle

Example:

M.plugin('qr').scan({
        flash: true,
        fadeToggle: true,
        orientation: 'LANDSCAPE',
        onscan: function( result ) {
                if ( result.status === 'NS' ) {
                        console.log('This QRCode Plugin is not supported');
                }
                else if ( result.status === 'CANCEL' ) {
                        console.log('Scanning is canceled');
                }
                else if ( result.status !== 'SUCCESS' ) {
                        if ( result.message ) {
                                console.log( result.status + ":" + result.message );
                        }
                        else {
                                console.log( 'This QRCode Plugin is failed' );
                        }
                }
                else {
                        if ( result.text ) {
                                console.log( result.format + ":" + result.text );
                        }
                        else {
                                console.log( 'QRCode data is not scanning' );
                        }
                }
        }
});
 // 캡쳐 범위 스케일 적용1
M.plugin('qr').scan({
        captureScale: {width:1.0, height:0.5},
        useGuideLine : true,
        callback: function( result, setting ) {
                  alert(result);
        },
});
// 캡쳐 범위 스케일 적용2
M.plugin('qr').scan({
        captureScale: {width:0.5, height:0.5},
        callback: function( result, setting ) {
                  alert(result);
        },
});
 // 커스텀 페이지 호출
M.plugin('qr').scan({
        page: 'CusomQRActivity',
        callback: function( result, setting ) {
                  alert(result);
        },
});
// QR 코드만 인식
M.plugin('qr').scan({
        filterType: "QRCODE",
        callback: function( result, setting ) {
                  alert(result);
        },
});

Orientation Type

  • 모든 Orientation 값은 Application 설정에 영향을 받음

  • Manifest.xml 에서도 orient 값이 DEFAULT 인 경우 Application 설정의 첫번째 값을 적용

Type

Int

Description

DEFAULT

0

Manifest.xml 에서 설정한 orient 값 적용

PORTRAIT

1

세로모드, 홈버튼이 아래인 세로 방향으로 회전 유지

PORT

1

PORTRAIT 을 축약

LANDSCAPE

2

가로모드, 왼쪽 회전된 상태 유지

LAND

2

LANDSCAPE 를 축약

PORTRAIT|REVERSE

3

세로모드, 세로 방향만 허용, 회전 가능

PORT|REVERSE

3

PORTRAIT 을 축약

PORTREV

3

PORTRAIT|REVERSE 를 축약

LANDSCAPE|REVERSE

4

가로모드, 가로 방향만 허용, 회전 가능

LAND|REVERSE

4

LANDSCAPE 를 축약

LANDREV

4

LANDSCAPE|REVERSE 를 축약

ALL

5

모든 방향으로 허용

filterType (Symbol)

  • 특정 Symbol만 스캔하고자 할때 선언

Type

Int

NONE

0

PARTIAL

1

EAN8

8

UPCE

9

ISBN10

10

UPCA

12

EAN13

13

ISBN13

14

I25

25

DATABAR

34

DATABAR_EXP

35

CODABAR

38

CODE39

39

PDF417

57

QRCODE

64

CODE93

93

CODE128

128

CPU TYPE 별 JNI 파일 다운로드

다운로드.

Customizing

커스터마이징()

QR 관련 기능을 커스터마이징 하기 위해서는 아래 절차를 이용해야 함

안드로이드 샘플 다운로드.

iOS 샘플 다운로드.

  1. Custom Activity / Custom ViewController 생성

    • Android : CaptureActivity 를 상속 받아, Activity 를 생성

    • iOS : MQRCodeViewController 를 상속 받아, ViewController 를 생성

  2. AndroidManifest.xml 에 custom activity 등록

  3. 버튼 등 layout 수정

    • Android : res > layout > capture.xml 수정

    • iOS : XIB 파일을 만들어 생성된 Custom ViewController 와 연동

  4. 사용 방법 : option.page 에 1번 항에서 생성된 activity 명을 선언

예시 :

M.plugin('qr').scan({
                        flash: true,
                        fadeToggle: true,
                        orientation: 'PORTRAIT',
                        useGuideLine : true,
                        page:'CustomQRActivity',
                        fileterType: "QRCODE",
                        onscan: function( result, setting ) {
                                if ( result.status === 'NS' ) {
                                        console.log('This QRCode Plugin is not supported');
                                }
                                else if ( result.status === 'CANCEL' ) {
                                        console.log('Scanning is canceled');
                                }
                                else if ( result.status !== 'SUCCESS' ) {
                                        if ( result.message ) {
                                                console.log( result.status + ":" + result.message );
                                        }
                                        else {
                                                console.log( 'This QRCode Plugin is failed' );
                                        }
                                }
                                else {
                                        if ( result.text ) {
                                                console.log( result.format + ":" + result.text );
                                        }
                                        else {
                                                console.log( 'QRCode data is not scanning' );
                                        }
                                }
                        }
                        });