BitsoundReceiver 1.6.1

BitsoundReceiver 1.6.1

wonje,songkeunhuijae-soundllydev-soundlly 维护。



  • wonje,song

BitsoundReceiver SDK for iOS

N|Bitsound

BitsoundReceiver SDK可以接收不可见音频,解码后获取beacon信息。查询beacon上注册的内容信息。《[Bitsound 文档](https://docs.bitsound.io/v1.0/docs/introduction)》

  • 接收不可见音频
  • 解码音频数据,查询beacon信息
  • 查询beacon上注册的内容信息并传递
  • 查询广告排期,传递广告内容
  • 检查排期,执行相关功能
  • 自定义日志发送

需求

iOS部署目标 8.0+,Xcode 8+

配置

iOS 10中的更改:之前Optional的`NSMicrophoneUsageDescription`在iOS 10更新后变成了必需项。这是在mic权限提示对话框中显示的文本。

在Xcode中选择Project的.plist文件,右键点击并选择Open As -> Source Code,然后添加以下XML代码。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 .
 .
 <key>NSMicrophoneUsageDescription</key>
 <string>광고 속 혜택 제공 기능(음파 서비스)에 사용 됩니다.</string>
 .
 .
</dict>
</plist>

使用

使用app密钥初始化

// init
[[BitsoundReceiver sharedInstance] initWithAppKey:@"your_app_key"];
// set delegate
[BitsoundReceiver sharedInstance].delegate = self;

开启摇晃功能

#pragma mark - BitsoundReceiverDelegate
- (void)receiverDidReceiveInitResult:(BitsoundReceiverInitResult)initResult error:(NSError *)error {
    if (initResult == BitsoundReceiverInitSuccess) {
        // init이 성공이면, startDetect가 가능합니다. startDetect 또는 enableShake + startDetect를 통해 신호를 감지합니다.
        // set delegate
        [BitsoundShaking sharedInstance].delegate = self;
        // enable shaking
        [[BitsoundShaking sharedInstance] enableShake];
    }
}

使用内容助手开始检测

#pragma mark - BitsoundShakingDelegate
- (void)shakingDidDetect {
    // 사용자에게 진동을 통해, shaking 되었다는것을 알려줍니다.
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    // start detect with contents assistant -> YES : 음파 수신 실패하면, 광고 컨텐츠 조회, NO : 음파 수신 시도하고 종료
    [[BitsoundReceiver sharedInstance] startDetectWithContentsAssistant:NO detectResult:^(BitsoundReceiverDetectResult result) {
        if (result == BitsoundReceiverSuccess) {
            // 신호 감지 시작 성공적.
        } else {
            // 신호 감지 시작 실패시 아래와 같은 종류의 코드가 반환됩니다.
            /**
             *	BitsoundReceiverDetectMicPermissionDenied, // mic. permission denied
             *	BitsoundReceiverDetectAlreadyStarted, // 이미 실행중임(동시에 안됨)
             *	BitsoundReceiverDetectNotInitialized, // SDK가 초기화 되지 않음
             */
        }
    }];
}

接收方已收到的结果

#pragma mark - BitsoundReceiverDelegate
- (void)receiverDidReceiveResult:(BitsoundReceiverResult)result contents:(BitsoundContentsModel *)contents {
    if (result == BitsoundReceiverSuccess) {
        if (NSClassFromString(@"SFSafariViewController")) {
            SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString: [contents getStrValue:@"url"]]];
            [self presentViewController:safariViewController animated:YES completion:^{
            }];
        } else {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString: [[contents getStrValue:@"url"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
        }
    }
}

许可

商业