SGQRCode Documentation

repository·master·Indexed 23 days ago

https://github.com/kingsic/sgqrcode

An iOS library for generating and scanning QR codes. It includes SGScanCode for scanning via camera or static images, SGGenerateQRCode for creating QR codes with optional logos, and utilities for managing camera/photo permissions (SGPermission) and flashlight control (SGTorch).

Tokens
599
Snippets
3
Records
8
Agent score
33%

What's inside SGQRCode

  1. Configure Info.plist permissions for SGQRCode

    master

    SGQRCode requires access to the camera and photo library. You must add the following keys to your Info.plist file to provide usage descriptions to the user:

    • NSCameraUsageDescription: For camera access.
    • NSPhotoLibraryUsageDescription: For photo library access.
  2. Troubleshoot CocoaPods installation errors

    master

    If you encounter the error [!] Unable to find a specification for SGQRCode during installation, run the following commands in your terminal to refresh your local pod specs:

    1. pod repo remove master
    2. pod setup
    pod repo remove master
    pod setup
  3. Implement SGScanCodeDelegate and SGScanCodeSampleBufferDelegate

    master

    Implement these delegate methods to handle scanning results and environmental changes like brightness.

    SGScanCodeDelegate Called when a QR code is successfully scanned.

    SGScanCodeSampleBufferDelegate Called to provide brightness information, which can be used to manage the flashlight (SGTorch).

    // SGScanCodeDelegate
    - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
        <#code#>
    }
    
    // SGScanCodeSampleBufferDelegate
    - (void)scanCode:(SGScanCode *)scanCode brightness:(CGFloat)brightness {
        <#code#>
    }
  4. Scan QR codes using SGScanCode

    master

    To implement QR code scanning, use the SGScanCode class. You must set a preview view and implement the SGScanCodeDelegate and SGScanCodeSampleBufferDelegate protocols.

    Note: Version 4.x uses a Delegate pattern, whereas version 3.5x used Blocks.

  5. Core Classes in SGQRCode

    master

    The following classes are the primary interfaces for the library:

    • SGScanCode: Handles QR code scanning.
    • SGScanViewConfigure: Configuration for the scanning view.
    • SGScanView: The scanning view component.
    • SGPermission: Manages camera and photo library permissions.
    • SGTorch: Manages the device flashlight.
    • SGQRCodeLog: Provides debugging logs.