1

I'm very much a beginner with iOS and the Plaid API, and I'm looking to make a budgeting app that collects users' existing bank transaction data using Plaid. I've currently successfully integrated bank account login with Plaid, but haven't been able to get much further.

Using the code provided in the Plaid iOS SDK, I am attempting to retrieve data on a user's bank account after they have logged in. However, every time I try to return the users' transactions using the provided SDK, I am faced with variables that return "null".

Below is some of my code:

PLDTransaction.m (from 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;
}

ViewController.h

#import "PLDTransaction.h"

@interface ViewController : UIViewController

@property (nonatomic, copy) PLDTransaction *accountInstance;

@end

ViewController.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];
     }];
}

The above code in ViewController.m returns:

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)
user6335453
  • 135
  • 2
  • 7

0 Answers0