<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.barion.com/index.php?action=history&amp;feed=atom&amp;title=App2App_integration_with_ios_library</id>
	<title>App2App integration with ios library - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://docs.barion.com/index.php?action=history&amp;feed=atom&amp;title=App2App_integration_with_ios_library"/>
	<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=App2App_integration_with_ios_library&amp;action=history"/>
	<updated>2026-11-25T00:53:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://docs.barion.com/index.php?title=App2App_integration_with_ios_library&amp;diff=1521&amp;oldid=prev</id>
		<title>Macika: Created page with &quot;__NOTOC__ In this type of integration, you don&#039;t need to edit your server-side (aside from the Universal link modifications). In your mobile application, you don&#039;t have to imp...&quot;</title>
		<link rel="alternate" type="text/html" href="https://docs.barion.com/index.php?title=App2App_integration_with_ios_library&amp;diff=1521&amp;oldid=prev"/>
		<updated>2019-02-07T11:17:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ In this type of integration, you don&amp;#039;t need to edit your server-side (aside from the Universal link modifications). In your mobile application, you don&amp;#039;t have to imp...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
In this type of integration, you don&amp;#039;t need to edit your server-side (aside from the Universal link modifications). In your mobile application, you don&amp;#039;t have to implement network communication. We already did it for you. If you use the Barion Android library you have to add a few lines of code to your existing codebase. The disadvantage of this is that you have to notify your own server-side about the payments and your mobile app can contain the POSKey.&lt;br /&gt;
&lt;br /&gt;
==Downloads, example==&lt;br /&gt;
You can download the Barion iOS Library from [https://github.com/barion/barion-ios-objc-app2app/tree/master/library Barion&amp;#039;s Github page].&lt;br /&gt;
&lt;br /&gt;
You can download the example project from [https://github.com/barion/barion-ios-objc-app2app/tree/master/examples/LibraryIntegration Barion&amp;#039;s Github page].&lt;br /&gt;
&lt;br /&gt;
The library contains the necessary models, so you don&amp;#039;t need to implement them.&lt;br /&gt;
&lt;br /&gt;
==Integration steps==&lt;br /&gt;
===0. step - Setup Universal link===&lt;br /&gt;
In order to the Barion mobile application to redirect the user to the integrator mobile application, you have to put one file into your website&amp;#039;s root directory. Your website have to support HTTPS protocol. Simply put a file into your website&amp;#039;s root directory with &amp;#039;&amp;#039;&amp;#039;apple-app-site-association&amp;#039;&amp;#039;&amp;#039; name and don&amp;#039;t write an extension to it. This file’s content should be something like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;applinks&amp;quot;:{&lt;br /&gt;
         &amp;quot;apps&amp;quot;:[],&lt;br /&gt;
         &amp;quot;details&amp;quot;:[&lt;br /&gt;
            {&lt;br /&gt;
               &amp;quot;appID&amp;quot;:&amp;quot;[your ios team id].[your application&amp;#039;s bundle id]&amp;quot;,&lt;br /&gt;
               &amp;quot;paths&amp;quot;:[&lt;br /&gt;
                  &amp;quot;*&amp;quot;&lt;br /&gt;
               ]&lt;br /&gt;
            }&lt;br /&gt;
         ]&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find your Team ID on this site: [https://developer.apple.com/membercenter/index.action#profile Organization Profile]&lt;br /&gt;
&lt;br /&gt;
Here you are a real example on [https://secure.barion.com/apple-app-site-association our website]. &lt;br /&gt;
&lt;br /&gt;
You can read more about Universal link in [https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html Apple&amp;#039;s documentation]&lt;br /&gt;
The Universal Link doesn&amp;#039;t work in simulator!&lt;br /&gt;
&lt;br /&gt;
===1. step - Setup your iOS application for Universal links===&lt;br /&gt;
Open the XCode, select your project and the target. Select the &amp;#039;&amp;#039;&amp;#039;Capabilities&amp;#039;&amp;#039;&amp;#039; tab and find the &amp;#039;&amp;#039;&amp;#039;Associated Domains&amp;#039;&amp;#039;&amp;#039; section! You need to add that domains that you have written in the 0.2 step:&lt;br /&gt;
[[File:Universallink.png|center|800px]]&lt;br /&gt;
As a result, this will generate a [ProjectName].entitlements file.&lt;br /&gt;
&lt;br /&gt;
===2. step - Setup your application to handle your own scheme.===&lt;br /&gt;
Switch to the &amp;#039;&amp;#039;&amp;#039;Info&amp;#039;&amp;#039;&amp;#039; tab, and open the &amp;#039;&amp;#039;&amp;#039;URL Types&amp;#039;&amp;#039;&amp;#039; section! Add your own url scheme just like on this image.&lt;br /&gt;
[[File:UrlScheme.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
===3. step - Add Barion iOS library to your project===&lt;br /&gt;
You can download the required files from [https://github.com/barion/barion-ios-objc-app2app/tree/master/library Barion&amp;#039;s Github page].&lt;br /&gt;
&lt;br /&gt;
Copy the &amp;#039;&amp;#039;&amp;#039;libBarioniOSLibrary.a&amp;#039;&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;&amp;#039;BarionBundle.bundle&amp;#039;&amp;#039;&amp;#039; files into your project&amp;#039;s root directory. Copy the &amp;#039;&amp;#039;&amp;#039;include&amp;#039;&amp;#039;&amp;#039; directory into your project directory. Pay attention that the &amp;#039;&amp;#039;&amp;#039;Copy items if needed&amp;#039;&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;&amp;#039;Create folder references&amp;#039;&amp;#039;&amp;#039; settings should be on.&lt;br /&gt;
&lt;br /&gt;
Select your project and the target. Find under the &amp;#039;&amp;#039;&amp;#039;Build settings&amp;#039;&amp;#039;&amp;#039; tab the &amp;#039;&amp;#039;&amp;#039;Other Linker Flags&amp;#039;&amp;#039;&amp;#039; option and add this &amp;#039;&amp;#039;&amp;#039;-ObjC&amp;#039;&amp;#039;&amp;#039; to it.&lt;br /&gt;
[[File:OtherLinkerflags.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
Check on the &amp;#039;&amp;#039;&amp;#039;Build Phases&amp;#039;&amp;#039;&amp;#039; tab that the &amp;#039;&amp;#039;&amp;#039;Link Binary With Libraries&amp;#039;&amp;#039;&amp;#039; section contains the &amp;#039;&amp;#039;&amp;#039;libBarioniOSLibrary.a&amp;#039;&amp;#039;&amp;#039; file, and in the &amp;#039;&amp;#039;&amp;#039;Copy Bundle Resources&amp;#039;&amp;#039;&amp;#039; section contains the &amp;#039;&amp;#039;&amp;#039;include&amp;#039;&amp;#039;&amp;#039; directory and the &amp;#039;&amp;#039;&amp;#039;BarionBundle.bundle&amp;#039;&amp;#039;&amp;#039; file.&lt;br /&gt;
[[File:CheckYourself.png|center|800px]]&lt;br /&gt;
&lt;br /&gt;
===4. step - Start payment===&lt;br /&gt;
You need to implement the BarionLibraryDelegate protocol in that UIViewController, which will start the payment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   // MainViewController.h&lt;br /&gt;
   #import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;
   #import &amp;quot;../include/BarioniOSLibrary/LibraryViewController.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   @interface MainViewController : UIViewController &amp;lt;UITableViewDataSource, UITableViewDelegate, BarionLibraryDelegate&amp;gt;&lt;br /&gt;
   {&lt;br /&gt;
      NSArray* _products;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   - (IBAction)payWithBarion:(id)sender;&lt;br /&gt;
&lt;br /&gt;
   @end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Import the required headers in the MainViewController.m file!&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
   #import &amp;quot;include/BarioniOSLibrary/PaymentSettings.h&amp;quot;&lt;br /&gt;
   #import &amp;quot;include/BarioniOSLibrary/TransactionModel.h&amp;quot;&lt;br /&gt;
   #import &amp;quot;include/BarioniOSLibrary/Product.h&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Implement the payWithBarion method. Initiate the payment and the library controller.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
   - (IBAction)payWithBarion:(id)sender&lt;br /&gt;
   {&lt;br /&gt;
      NSMutableArray* result = [NSMutableArray new];&lt;br /&gt;
      [_products addObject: [[Product alloc] initUsingBlock:^(Product *product) {&lt;br /&gt;
         product.name = @&amp;quot;The history of money&amp;quot;;&lt;br /&gt;
         product.productDescription = @&amp;quot;The evolution of money from the stoneage to Barion&amp;quot;;&lt;br /&gt;
         product.quantity = 1;&lt;br /&gt;
         product.unit = @&amp;quot;db&amp;quot;;&lt;br /&gt;
         product.price = 40;&lt;br /&gt;
         product.itemTotal = 40;&lt;br /&gt;
         product.SKU = @&amp;quot;APP2APP_PENZTORT&amp;quot;;&lt;br /&gt;
      }]];&lt;br /&gt;
      [_products addObject: [[Product alloc] initUsingBlock:^(Product *product) {&lt;br /&gt;
         product.name = @&amp;quot;How to make a fortune with Barion&amp;quot;;&lt;br /&gt;
         product.productDescription = @&amp;quot;Tips to get rich&amp;quot;;&lt;br /&gt;
         product.quantity = 1;&lt;br /&gt;
         product.unit = @&amp;quot;db&amp;quot;;&lt;br /&gt;
         product.price = 20;&lt;br /&gt;
         product.itemTotal = 20;&lt;br /&gt;
         product.SKU = @&amp;quot;APP2APP_GETRICH&amp;quot;;&lt;br /&gt;
      }]];&lt;br /&gt;
      [_products addObject: [[Product alloc] initUsingBlock:^(Product *product) {&lt;br /&gt;
         product.name = @&amp;quot;The beginners guide to accepting bank cards&amp;quot;;&lt;br /&gt;
         product.productDescription = @&amp;quot;How to become bank card acceptors in five minutes with Barion&amp;quot;;&lt;br /&gt;
         product.quantity = 1;&lt;br /&gt;
         product.unit = @&amp;quot;db&amp;quot;;&lt;br /&gt;
         product.price = 140;&lt;br /&gt;
         product.itemTotal = 140;&lt;br /&gt;
         product.SKU = @&amp;quot;APP2APP_BEGGUIDE&amp;quot;;&lt;br /&gt;
      }]];&lt;br /&gt;
&lt;br /&gt;
      TransactionModel *transactionSettings = [[TransactionModel alloc] initUsingBlock:^(TransactionModel *settings){&lt;br /&gt;
         settings.posTransactionId = @&amp;quot;TEST-01-App2App&amp;quot;;&lt;br /&gt;
         settings.payee = [Parameters examplePayee];&lt;br /&gt;
         settings.total = [self getProductsTotal];&lt;br /&gt;
         settings.comment = @&amp;quot;Barion app2app ios library&amp;quot;;&lt;br /&gt;
      }];&lt;br /&gt;
    &lt;br /&gt;
      PaymentSettings *paymentSettings = [[PaymentSettings alloc] initUsingBlock:^(PaymentSettings *settings){&lt;br /&gt;
         settings.posKey = [Parameters posKey];&lt;br /&gt;
         settings.paymentTypeEnum = Immediate;&lt;br /&gt;
         settings.guestCheckOut = YES;&lt;br /&gt;
         settings.debugMode = YES;&lt;br /&gt;
         settings.locale = @&amp;quot;hu-HU&amp;quot;;&lt;br /&gt;
         settings.fundingSourceEnum = All;&lt;br /&gt;
         settings.redirectUrl = [Parameters redirectUrl];&lt;br /&gt;
         settings.redirectUrliOS9 = [Parameters redirectUrl];&lt;br /&gt;
      }];&lt;br /&gt;
    &lt;br /&gt;
      UIStoryboard *sb = [UIStoryboard storyboardWithName:@&amp;quot;LibraryMain&amp;quot; bundle:&lt;br /&gt;
         [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@&amp;quot;BarionBundle&amp;quot; withExtension:@&amp;quot;bundle&amp;quot;]]];&lt;br /&gt;
      ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController = (LibraryViewController*)[sb instantiateInitialViewController];&lt;br /&gt;
      ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController.delegate = self;&lt;br /&gt;
      ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController.productList = [_products mutableCopy];&lt;br /&gt;
      ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController.transactionSettings = transactionSettings;&lt;br /&gt;
      ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController.paymentSettings = paymentSettings;&lt;br /&gt;
      [self presentViewController: ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController animated:YES completion:nil];&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If there was an error in your payment initiation, you will be notified through the barionLibraryStatus method:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
   - (void)barionLibraryStatus:(NSMutableDictionary *)response&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After this the library will automatically open the Barion mobile application or redirect the user to Barion&amp;#039;s website.&lt;br /&gt;
&lt;br /&gt;
===5. step - Handling redirect===&lt;br /&gt;
Add these methods to your application&amp;#039;s AppDelegate.m file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
   -(void)applicationWillEnterForeground:(UIApplication *)application {&lt;br /&gt;
    NSString *paymentId = ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController.paymentId;&lt;br /&gt;
    if (paymentId != nil) {&lt;br /&gt;
        [LibraryViewController getPaymentStateWithPaymentId:paymentId withPOSKey:[Parameters posKey] inDebugMode:[Parameters debugMode] andWithCallback:^(NSDictionary* response){&lt;br /&gt;
            NSLog(@&amp;quot;continue block runned&amp;quot;);&lt;br /&gt;
            [self openPaymentResultViewControllerWithPaymentId:paymentId orWithUrl:nil];&lt;br /&gt;
            ((AppDelegate*)[UIApplication sharedApplication].delegate).libraryViewController = nil;&lt;br /&gt;
        }];&lt;br /&gt;
    }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   - (void)openPaymentResultViewControllerWithPaymentId:(NSString*)paymentId orWithUrl:(NSURL*)url {&lt;br /&gt;
      UIStoryboard* sb = [UIStoryboard storyboardWithName: @&amp;quot;Main&amp;quot; bundle:nil];&lt;br /&gt;
      PaymentResultViewController* result = [sb instantiateViewControllerWithIdentifier:@&amp;quot;paymentResultViewController&amp;quot;];&lt;br /&gt;
      result.paymentId = paymentId;&lt;br /&gt;
      result.url = url;&lt;br /&gt;
      result.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;&lt;br /&gt;
      UINavigationController* controller = (UINavigationController*)self.window.rootViewController;&lt;br /&gt;
      [[controller presentedViewController] dismissViewControllerAnimated: YES completion:^{&lt;br /&gt;
          [controller setViewControllers: [NSArray arrayWithObject: result]];&lt;br /&gt;
      }];&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===6. step - Get payment&amp;#039;s status===&lt;br /&gt;
After the user returns your application, you should get the payment&amp;#039;s status. In this example we use &amp;#039;&amp;#039;&amp;#039;PaymentResultViewController&amp;#039;&amp;#039;&amp;#039; class for this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   // PaymentResultViewController.h&lt;br /&gt;
   #import &amp;lt;UIKit/UIKit.h&amp;gt;&lt;br /&gt;
   #import &amp;quot;GetPaymentStateConnectionHandler.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   @interface PaymentResultViewController : UIViewController &amp;lt;GetPaymentStateConnectionHandlerDelegate&amp;gt;&lt;br /&gt;
   {&lt;br /&gt;
      GetPaymentStateConnectionHandler* _getPaymentStateHandler;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   @property (nonatomic, retain) NSURL* url;&lt;br /&gt;
   @property (nonatomic, retain) NSString* paymentId;&lt;br /&gt;
&lt;br /&gt;
   @end&lt;br /&gt;
&lt;br /&gt;
   // PaymentResultViewController.m&lt;br /&gt;
   #import &amp;quot;PaymentResultViewController.h&amp;quot;&lt;br /&gt;
   #import &amp;quot;BarionError.h&amp;quot;&lt;br /&gt;
   #import &amp;quot;BarionGetPaymentStateResponse.h&amp;quot;&lt;br /&gt;
   #import &amp;quot;Parameters.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   @implementation PaymentResultViewController&lt;br /&gt;
&lt;br /&gt;
   - (void)viewDidLoad {&lt;br /&gt;
      [super viewDidLoad];&lt;br /&gt;
&lt;br /&gt;
       if (self.url != nil) {&lt;br /&gt;
           [LibraryViewController getPaymentStateWithUrl:self.url withPOSKey:[Parameters posKey] inDebugMode:[Parameters debugMode] andWithCallback:^(NSDictionary* response){&lt;br /&gt;
               // The response dictionary contains the payment details&lt;br /&gt;
           }];&lt;br /&gt;
        } else if (self.paymentId != nil){&lt;br /&gt;
           [LibraryViewController getPaymentStateWithPaymentId:self.paymentId  withPOSKey: [Parameters posKey] inDebugMode: [Parameters debugMode] andWithCallback:^(NSDictionary* response){&lt;br /&gt;
              // The response dictionary contains the payment details&lt;br /&gt;
           }];&lt;br /&gt;
        }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   @end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the dictionary you can easily get the payment details.&lt;/div&gt;</summary>
		<author><name>Macika</name></author>
	</entry>
</feed>