iosdev_notes icon indicating copy to clipboard operation
iosdev_notes copied to clipboard

集成第三方服务遇到的坑

Open sauchye opened this issue 8 years ago • 7 comments

集成科大讯飞语音

  • 由于最近集成科大讯飞服务,遇到一些坑,= =,特此记录一下。
  • 语音合成的是pcm文件,pcmwav
  • 如果需要转换成MP3格式需要借助lame,第二部依然得进行~
+ (NSData *)writeWaveHead:(NSData *)audioData
               sampleRate:(long)sampleRate {
            Byte waveHead[44];
            waveHead[0] = 'R';
            waveHead[1] = 'I';
            waveHead[2] = 'F';
    waveHead[3] = 'F';
        long totalDatalength = [audioData length] + 44;
    waveHead[4] = (Byte)(totalDatalength & 0xff);
    waveHead[5] = (Byte)((totalDatalength >> 8) & 0xff);
    waveHead[6] = (Byte)((totalDatalength >> 16) & 0xff);
    waveHead[7] = (Byte)((totalDatalength >> 24) & 0xff);
    waveHead[8] = 'W';
    waveHead[9] = 'A';
    waveHead[10] = 'V';
    waveHead[11] = 'E';
    waveHead[12] = 'f';
    waveHead[13] = 'm';
    waveHead[14] = 't';
    waveHead[15] = ' ';
    waveHead[16] = 16;
    //size of 'fmt '
    waveHead[17] = 0;     waveHead[18] = 0;     waveHead[19] = 0;          waveHead[20] = 1;
    //format
    waveHead[21] = 0;          waveHead[22] = 1;
    //chanel
    waveHead[23] = 0;
    waveHead[24] = (Byte)(sampleRate & 0xff);
    waveHead[25] = (Byte)((sampleRate >> 8) & 0xff);
    waveHead[26] = (Byte)((sampleRate >> 16) & 0xff);
    waveHead[27] = (Byte)((sampleRate >> 24) & 0xff);
    long byteRate = sampleRate * 2 * (16 >> 3);;
    waveHead[28] = (Byte)(byteRate & 0xff);
    waveHead[29] = (Byte)((byteRate >> 8) & 0xff);
    waveHead[30] = (Byte)((byteRate >> 16) & 0xff);
    waveHead[31] = (Byte)((byteRate >> 24) & 0xff);
    waveHead[32] = 2*(16 >> 3);     waveHead[33] = 0;
    waveHead[34] = 16;     waveHead[35] = 0;
    waveHead[36] = 'd';     waveHead[37] = 'a';
    waveHead[38] = 't';     waveHead[39] = 'a';
    long totalAudiolength = [audioData length];
    waveHead[40] = (Byte)(totalAudiolength & 0xff);
    waveHead[41] = (Byte)((totalAudiolength >> 8) & 0xff);
    waveHead[42] = (Byte)((totalAudiolength >> 16) & 0xff);
    waveHead[43] = (Byte)((totalAudiolength >> 24) & 0xff);
    NSMutableData * pcmData = [[NSMutableData alloc]initWithBytes:&waveHead length:sizeof(waveHead)];
    [pcmData appendData:audioData];

    return pcmData;
}

集成支付宝支付

rsa_private read error : private key is NULL

1解决方法:
1)在RSADataSigner.m文件中 搜索代码 [result appendString:@"-----BEGIN PRIVATE KEY-----\n"]; 将其改成 [result appendString:@"-----BEGIN RSA PRIVATE KEY-----\n"];
2)在RSADataSigner.m文件中 搜索代码 [result appendString:@"\n-----END PRIVATE KEY-----"]; 将其改成 [result appendString:@"\n-----END RSA PRIVATE KEY-----"];

参考:http://blog.csdn.net/vkooy/article/details/47130653

sauchye avatar Mar 18 '16 11:03 sauchye

UMengFeedback

 'UMengFeedback/UMFeedback_iOS_2.3.4/UMengFeedback_SDK/libUMFeedback.a(UMFeedback.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

UMengShare

  • 如果不设置一些字段导致无法跳转到微信
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    UMShareWebpageObject *shareObject = [[UMShareWebpageObject alloc] init];
    shareObject.title = text; 
    shareObject.webpageUrl    = url;
    shareObject.descr = @"";

    NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imageUrl]];
    shareObject.thumbImage = data?data:[ZTYTools getAppIcon];
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    UMSocialPlatformType platformType = UMSocialPlatformType_WechatTimeLine;

    [[UMSocialManager defaultManager] shareToPlatform:platformType
                                        messageObject:messageObject
                                currentViewController:vc completion:^(id data, NSError *error) {      
    }];


facebook
    [FBSDKSettings setAppID:@"xxxx"];
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Facebook appKey:@"xxxx " appSecret:nil redirectURL:redirectURL];


sauchye avatar Aug 24 '16 03:08 sauchye

申请Apple 开发者账号 有些邮箱域名无法注册,🐧邮箱可以

sauchye avatar Apr 03 '18 08:04 sauchye

 sd_setImageWithURL 无法解析带空格的字符串 导致内存暴涨

sauchye avatar May 11 '18 07:05 sauchye

'UMengFeedback/UMFeedback_iOS_2.3.4/UMengFeedback_SDK/libUMFeedback.a(UMFeedback.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)  

这个怎么解决??

okerivy avatar Aug 17 '18 03:08 okerivy

@okerivy 您看看是不否开启了 bitcode ,尝试关闭,再查查UMengFeedback路径问题,您不是pod引入吗 o(╯□╰)o

sauchye avatar Aug 17 '18 03:08 sauchye

PalPay iOS SDK接入流程

1、进入官网开发者教程https://developer.paypal.com/

2、注册美区的PayPal账户账号

https://developer.paypal.com/developer/applications/

3、配置live和sandbox key、Webhooks url地址 jietu20190219-155005

4、SDK集成

pod 'PayPal-iOS-SDK'

#import "PayPalMobile.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//// sandboxString  productionString key 
	    [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction: productionString,
                                                           PayPalEnvironmentSandbox: sandboxString}];

}

到对应的控制器集成

#import <PayPalMobile.h>

@property (nonatomic, strong, readwrite) PayPalConfiguration *payPalConfig;

- (void)configPayPal{
    _payPalConfig = [[PayPalConfiguration alloc] init];
    _payPalConfig.acceptCreditCards = NO;
    _payPalConfig.merchantName = @"SAUCHYE INC";////商家用户名
    _payPalConfig.merchantPrivacyPolicyURL = [NSURL URLWithString:@"https://www.sauchye.com"];
    _payPalConfig.merchantUserAgreementURL = [NSURL URLWithString:@"https://www.sauchye.com"];
    _payPalConfig.languageOrLocale = [[NSBundle mainBundle] preferredLocalizations].firstObject;
    //[NSLocale preferredLanguages][0];
    _payPalConfig.payPalShippingAddressOption = PayPalShippingAddressOptionNone;
    NSLog(@"PayPal iOS SDK version: %@", [PayPalMobile libraryVersion]);
    [PayPalMobile preconnectWithEnvironment:PayPalEnvironmentProduction];
}

创建订单

- (void)presentPayPal{
    NSString *currency = @"USD";
    PayPalItem *item = [PayPalItem itemWithName:merchantName
                                   withQuantity:1
                                      withPrice:[NSDecimalNumber decimalNumberWithString:self.price]
                                   withCurrency:currency
                                        withSku:@"shoxot goods"];
    NSArray *items = @[item];
    NSDecimalNumber *subtotal = [PayPalItem totalPriceForItems:items];
    
    PayPalPayment *payment   = [[PayPalPayment alloc] init];
    payment.amount           = subtotal;
    payment.currencyCode     = currency;
    payment.shortDescription = merchantName;
    payment.items            = items;
    payment.invoiceNumber    = self.orderId;
    payment.intent           = PayPalPaymentIntentSale;
    PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc] initWithPayment:payment
                                                                                                configuration:self.payPalConfig
                                                                                                     delegate:self];
    
    if (!payment.processable) {
        // This particular payment will always be processable. If, for
        // example, the amount was negative or the shortDescription was
        // empty, this payment wouldn't be processable, and you'd want
        // to handle that here.
    }
    
    if (!paymentViewController) {
        return;
    }
    [self.viewController presentViewController:paymentViewController animated:YES completion:nil];
}

支付完成回调逻辑处理

#pragma mark - PayPalPaymentDelegate
- (void)payPalPaymentDidCancel:(PayPalPaymentViewController *)paymentViewController {
    NSLog(@"payPalPaymentDidCancel");
    [self.viewController dismissViewControllerAnimated:YES completion:nil];
}


- (void)payPalPaymentViewController:(nonnull PayPalPaymentViewController *)paymentViewController
                 didCompletePayment:(nonnull PayPalPayment *)completedPayment{
    NSLog(@"payPalPaymentViewController");
}


//// 支付完成 与服务器校验
- (void)payPalPaymentViewController:(nonnull PayPalPaymentViewController *)paymentViewController
                willCompletePayment:(nonnull PayPalPayment *)completedPayment
                    completionBlock:(nonnull PayPalPaymentDelegateCompletionBlock)completionBlock{
    [self.viewController dismissViewControllerAnimated:YES completion:nil];
    NSLog(@"payPalPaymentViewController  willCompletePayment:\n\n%@\n\nSend this to your server for confirmation and fulfillment.", completedPayment.confirmation);
    NSLog(@"paypal pay success");    
    NSDictionary *confirmation   = completedPayment.confirmation;
    NSString *currencyCode       = completedPayment.currencyCode;
    NSDecimalNumber *amount      = completedPayment.amount;
    NSDictionary *response       = [confirmation objectForKey:@"response"];
    NSString *ppOrderId          = [response objectForKey:@"id"];
    NSDictionary *parameters = @{@"amount":amount,
                                 @"currency_code":currencyCode,
                                 @"recharge_sn":ppOrderId,
                                 @"order_sn":self.orderId,
                                 @"create_time":[response objectForKey:@"create_time"]
                                 };
  
}

sauchye avatar Feb 19 '19 08:02 sauchye

[✓] Flutter (Channel beta, v1.1.8, on Mac OS X 10.14.3 18D109, locale zh-Hans-US)
    • Flutter version 1.1.8 at /Users/sauchye/Workspace/config/flutter
    • Framework revision 985ccb6d14 (7 weeks ago), 2019-01-08 13:45:55 -0800
    • Engine revision 90fcaff900
    • Dart version 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/sauchye/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[!] IntelliJ IDEA Ultimate Edition (version 2018.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.io/intellij-setup/#installing-the-plugins

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.

https://github.com/flutter/flutter/issues/11940

sauchye avatar Feb 24 '19 14:02 sauchye