尝试合并解析和paypal项目时出错

时间:2015-02-14 16:16:06

标签: ios swift paypal parse-platform

我试图将一个解析项目与paypal项目合并,但我遇到了这个错误:

Terminating app due to uncaught exception 'PayPalIncompleteIntegration', 
reason: 'preconnectWithEnvironment was called without a preceding call to initializeWithClientIdsForEnvironments

这是我发现的唯一与此错误相关的代码(MainViewController.swift):

class MainViewController: UIViewController, PayPalPaymentDelegate,
PayPalFuturePaymentDelegate, PayPalProfileSharingDelegate,
FlipsideViewControllerDelegate {
var environment:String = PayPalEnvironmentNoNetwork {
willSet(newEnvironment) {
  if (newEnvironment != environment) {
    PayPalMobile.preconnectWithEnvironment(newEnvironment)
  }
 }
}

.
. etc..
.


override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
PayPalMobile.preconnectWithEnvironment(environment)
}

这是来自PayPalMobile.h:

/// You MUST preconnect to PayPal to prepare the device for processing payments.
/// This improves the user experience because it allows the PayPal Mobile SDK to make its
/// setup request early and in the background.
///
/// The preconnect is valid for a limited time, so the recommended time to preconnect
/// is when you present the UI in which users *might* choose to initiate payment.
///
/// Calling this method a second time, with a different value, will change the environment used
/// by subsequently allocated PayPal Mobile SDK viewcontrollers. Existing viewcontrollers
/// will be unaffected.
///
/// @param environment
/// The PayPal Mobile SDK can operate in different environments to facilitate development and testing.
/// See PayPalEnvironmentProduction, PayPalEnvironmentSandbox,
PayPalEnvironmentNoNetwork for more details.
+ (void)preconnectWithEnvironment:(NSString *)environment;

(我也合并了两个故事板)

有人可以帮助我吗?谢谢!

1 个答案:

答案 0 :(得分:1)

戴夫来自PayPal。

@IceHell,您正在寻找的示例代码为here in ZZAppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

#warning "Enter your credentials"
  [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction : @"YOUR_CLIENT_ID_FOR_PRODUCTION",
                                                         PayPalEnvironmentSandbox : @"YOUR_CLIENT_ID_FOR_SANDBOX"}];
  return YES;
}

除了使用我们的示例代码之外,在使用PayPal iOS SDK之前,您还需要仔细查看我们的详细integration instructions