iOS通知-语音播报

一. UNNotificationServiceExtension
server-------> APNS------> extension(增加) -------->App
extension的简单介绍: http://www.jianshu.com/p/e458879f188d?appinstall=0
extension中自定义通知 http://www.jianshu.com/p/78ef7bc0465
Demo http://www.cocoachina.com/ios/20161017/17769.html
通知入门:(: 徐不同)
本地通知 http://www.jianshu.com/p/f5337e8f336d
http://www.jianshu.com/p/3d602a60ca4f
支付宝语音播报原理: http://www.jianshu.com/p/6a1115a17f85

一. 数字转字符串


- (void)transferMoney {
    NSString *money = @"12.02";
    
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterSpellOutStyle;
    formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_Hans"];
    NSNumber *num = [[[NSNumberFormatter alloc] init] numberFromString: money];
    NSString *zh_num = [formatter stringFromNumber:num];
   
    NSLog(@"转换后:%@",zh_num);
    
    //初始化语音播报
    AVSpeechSynthesizer * av = [[AVSpeechSynthesizer alloc]init];
    //设置播报的内容
    AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc]initWithString:zh_num];
    //设置语言类别
    AVSpeechSynthesisVoice * voiceType = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
    utterance.voice = voiceType;
    //设置播报语速
    utterance.rate = 0.5;
    [av speakUtterance:utterance];
    
}

你可能感兴趣的:(iOS通知-语音播报)