1

我是 iOS 和 Plaid API 的初学者,我正在寻找一个预算应用程序,使用 Plaid 收集用户现有的银行交易数据。我目前已经成功地将银行账户登录与 Plaid 集成在一起,但还没有取得更多进展。

使用 Plaid iOS SDK 中提供的代码,我尝试在用户登录后检索用户银行帐户中的数据。但是,每次我尝试使用提供的 SDK 返回用户的交易时,我都会遇到以下变量返回“空”。

下面是我的一些代码:

PLDTransaction.m(来自 Plaid iOS SDK)

- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
  if (self = [super init]) {
    _id = dictionary[@"_id"];
    _accountId = dictionary[@"_account"];
    _pendingTransactionId = dictionary[@"_pendingTransaction"];

    _amount = [dictionary[@"amount"] floatValue];
    _date = dictionary[@"date"];
    _name = dictionary[@"name"];

    NSDictionary *meta = dictionary[@"meta"];
    NSDictionary *location = meta[@"location"];
    NSDictionary *contact = meta[@"contact"];
    if (location) {
      _location = [[PLDTransactionLocation alloc] initWithDictionary:location];
    }
    if (contact) {
      _contact = [[PLDTransactionContact alloc] initWithDictionary:contact];
    }

    _isPending = [dictionary[@"pending"] boolValue];
    _category = [[PLDCategory alloc] 
initWithTransactionDictionary:dictionary];
    _score = dictionary[@"score"];
  }
  return self;
}

视图控制器.h

#import "PLDTransaction.h"

@interface ViewController : UIViewController

@property (nonatomic, copy) PLDTransaction *accountInstance;

@end

视图控制器.m

#import <LinkKit/LinkKit.h>
#import "ViewController.h"

@synthesize accountInstance = _accountInstance;

- (void)linkViewController:(PLKPlaidLinkViewController*)linkViewController
 didSucceedWithPublicToken:(NSString*)publicToken
                  metadata:(NSDictionary<NSString*,id>* _Nullable)metadata {
    [self dismissViewControllerAnimated:YES completion:^{
        // Handle success, e.g. by storing publicToken with your service
        NSLog(@"Successfully linked account! \nmetadata: %@", metadata);
        NSObject *checking = [_accountInstance initWithDictionary:metadata];
        NSLog(@"CHECKING: %@", checking);
        NSLog(@"INSTANCE: %@", _accountInstance);
        NSLog(@"TRANSACTION ID: %@", _accountInstance.pendingTransactionId);

        [self handleSuccessWithToken:publicToken metadata:metadata];
     }];
}

ViewController.m 中的上述代码返回:

Successfully linked account!
metadata: {
    account =     {
        id = "<null>";
        name = "<null>";
    };
    "account_id" = "<null>";
    institution =     {
        name = Citi;
        type = citi;
    };
    "plaid_api_request_id" = "<null>";
    "request_id" = NeDdn;
    status = connected;
}
CHECKING: (null)
INSTANCE: (null)
TRANSACTION ID: (null)
4

0 回答 0