Square connect API - Navigate back to app

241 views Asked by At

I am able to open Register app from my app on iPad by passing amount.

enter image description here

Now, when I cancel this by clicking on X at top left, Register app doesn not open back my app.

Versions : 
iOS : 10.1.1
Register App : 4.54.1
Xcode : 8.2

Any suggestions ? What I am missing ?

Code :

if (totalAmount)
{
    NSError *error = nil;
    SCCMoney *amount = [SCCMoney moneyWithAmountCents:9000 currencyCode:@"USD" error:&error];
    if (error)
        return;

    NSURL *const callbackURL = [NSURL URLWithString:@"myapp-callback://abc"];
    SCCAPIRequest *request = [SCCAPIRequest requestWithCallbackURL:callbackURL
                                                            amount:amount
                                                    userInfoString:@"Info"
                                                        merchantID:nil
                                                             notes:@"Coffee"
                                                        customerID:nil
                                              supportedTenderTypes:SCCAPIRequestTenderTypeAll
                                                 clearsDefaultFees:NO
                                   returnAutomaticallyAfterPayment:YES
                                                             error:&error];

    if (![SCCAPIConnection performRequest:request error:&error])
    {
        DLog(@"Error with Register Payment");
    }
}

Callback URL setup :

Xcode

enter image description here

Square Developer portal

enter image description here

2

There are 2 answers

0
tristansokol On BEST ANSWER

You probably haven't registered myapp-callback://abc for your application.

If you look at the first step on this page: https://docs.connect.squareup.com/articles/register-api-ios/

You'll need to add a URL scheme for your app to your info.plist like the Hello Charge sample has below, I'm guessing you don't have myapp-callback://abc in there and Square Register is unable to switch back to your app. plist example

0
Maulik On

OK I got the issue.

URL scheme should be same in info.plist and at developer portal.

In my case it was myapp-callback://abc in info.plist and myapp-callback at developer portal.