Henry Short

Henry Short

1602224280

React Native Klarna In-App SDK

React Native Klarna In-App SDK

This library wraps Klarna’s In-App SDK and exposes its functionality as React Native components. It currently supports Klarna Payments via a Payment View component.

This repository also includes a test application that you can use to see how it works.

Looking for the pure native Klarna In-App SDK? Check out the Klarna In-App SDK repo instead.

Requirements

  • iOS 10 or later.
  • Android 4.4 or later.

Klarna In-App SDK documentation

Overview of the SDK

What Does React Native Klarna In-App SDK Offer?

This library allows React Native apps to add views with Klarna content to their app. We currently support Klarna Payments, allowing you to add payment views to your checkout and authorizing a session to create an order natively.

Why should you use the SDK?

The SDK removes any possible friction in your app’s checkout flow by leveraging native functionality in iOS and Android. Some of the things the SDK does are:

  • Plays nicely with 3rd-party apps. Many customers complete their purchase through their banking application or other 3rd-party apps. We make this experience seamless not just by opening these apps, but returning your users automatically when they’re done.
  • Safeguards your users’ identity. The SDK adds an extra layer of security lowering the risk of fraudulent purchases. It also insures that your customer doesn’t have to write in any redundant info. (e.g. address or credentials) on successive purchases.
  • Improves 3D Secure flow. If certain payment methods require opening banking pages, we’ll display an in-app browser. Your customer can safely authenticate with their bank without ever leaving your app.
  • Open links without making your customers leave your app. As with 3D Secure, we open most resources in an in-app browser or a fullscreen overlay. This insures that your customer doesn’t ever have to leave your app.

Getting started

$ npm install react-native-klarna-inapp-sdk --save

Mostly automatic installation

$ react-native link react-native-klarna-inapp-sdk

Manual installation

iOS

We strongly encourage you to use CocoaPods to manage the library and follow the instructions below to add the SDK as a dependency to the React Native app. If you add the SDK to CocoaPods elsewhere in the application it may cause the SDK to not be visible to the library.

  1. After running $ npm install react-native-klarna-inapp-sdk --save go to [your project]/ios folder.
  2. Make sure you have a Podfile ready, if not use pod init. Check that platform :ios, ‘10.0’.
  3. Go to [your project]/node_modules/react-native-klarna-inapp-sdk/react-native-klarna-inapp-sdk.podspec and make sure that s.dependency ‘KlarnaMobileSDK’, ’~> 2.0.12 and s.platform = :ios, “10.0”.
  4. Add react-native-klarna-inapp-sdk as a dependency to your podfile ([your project]/ios folder)  pod ‘react-native-klarna-inapp-sdk’, :podspec => ‘../node_modules/react-native-klarna-inapp-sdk/react-native-klarna-inapp-sdk.podspec’.
  5. Go back to [your project]/ios and run pod install.

Note: If you encounter the build failure error Library not loaded: @rpath/libswiftCore.dylib, then you might need to create a Swift Bridging Header. to do so, please follow the steps below:

  • In XCode, create a new .swift file in the project.
  • A prompt window would ask you if you want to configure the Bridging Header, choose yes.
  • Clean the project and DerivedData.
  • Build the project.
Android
  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.klarna.inapp.sdk.KlarnaPaymentViewPackage; to the imports at the top of the file
  • Add new KlarnaPaymentViewPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':react-native-klarna-inapp-sdk'
    project(':react-native-klarna-inapp-sdk').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-klarna-inapp-sdk/android')
    
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

    compile project(':react-native-klarna-inapp-sdk')
    
    

Note: If you encounter any build failure errors regarding the androidx.annotations package missing, you should enable react-native-jetifier in the gradle.properties file inside your project. See how to enable this here.

Warning regarding Android integration

Both the iOS and Android integrations depend on the native SDK.

We’ve experienced issues with React Native 59 and above where 3rd party Gradle repositories won’t be recognized in the Android project’s build.gradle. To address this, you’ll need to add a reference to the repository in your own app’s build.gradle.

You can do it by adding the lines between the comments below:

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        // Add the lines below vvv
        maven {
            url 'https://x.klarnacdn.net/mobile-sdk/'
        }
        // Add the lines above ^^^
    }
}

Usage

You can import the KlarnaPaymentView from the library. You’ll then be able to add it as a component to your app. This component exposes callbacks as props and methods you can call via the compoent’s ref.

The view will self-size height-wise and grow it fill it containing view’s width.

Props

It has the following props:

Name Type Description
category String The payment method category you want to render in your view.
onInitialized () => {} The initialize call succeeded.
onLoaded () => {} The load call succeeded.
onLoadedPaymentReview () => {} The load payment review call succeeded.
onAuthorized ({}) => {} The authorize call succeeded.
onReauthorized ({}) => {} The reauthorize call succeeded.
onFinalized ({}) => {} The finalize call succeeded.
onError ({}) => {} An error occurred.

Prop callback parameters

The onAuthorized, onReauthorized, onFinalized and onError will provide an object (via nativeEvent) with the following parameters:

authorized: Boolean

Determines whether the previous operation was successful and yielded an authorization token.

Available on:
  • onAuthorized
  • onReauthorized
  • onFinalized
authToken: String | undefined

If authorize(), reauthorize() or finalize() succeeded, they will return a token you can submit to your backend.

Available on:
  • onAuthorized
  • onReauthorized
  • onFinalized

finalizeRequired: Boolean | undefined

If authorize() requires that you additionally call finalize(), .

Available on:
  • onAuthorized
error: Object | undefined

If a method failed, onError() will let you know via an error object.

Available on:
  • onError

View methods

Each payment view exposes a set of methods via a view’s ref. You can see in the test app or in the below example how these can be called. The methods are the following:

initialize()

Initializes the view with a session token. You have to have added the view to your application and supplied a payment method category.

Parameters
Name Type Description
sessionToken String The session token you get from Klarna.
returnUrl String An app-defined URL scheme the component uses to return customers to your app.
Return URL

You can read more about how the return URL works and how to add it tou your iOS application here and for your Android application here.

load()

Loads the view. This will render content in the view.

Parameters
Name Type Description
sessionData `String undefined`
loadPaymentReview()

Renders a description of the payment terms your customer has agreed to.

Once a session is authorized, you can then either render a payment review in the existing payment view or initialize() a new payment view with the same session token and call this method.

Note:

This only works with specific payment methods and countries.

authorize()

Authorizes the payment session.

Parameters
Name Type Description
autoFinalize `String undefined`
sessionData `String undefined`
reauthorize()

If the details of the session (e.g. cart contents, customer data) have changed, call this to update the session and get a new authorization token.

Parameters
Name Type Description
sessionData `String undefined`
finalize()

If a specific payment method needs you to trigger a second authorization, call finalize when you’re ready.

Parameters
Name Type Description
sessionData `String undefined`

More information

You can read more about refs and how they’re used here. If you’d like to understand what each method does, you can read about it on Klarna Developers.

Example

In addition to the test app in /TestApp, the you can see an abridged version below.

import KlarnaPaymentView from 'react-native-klarna-inapp-sdk';

class MyCheckoutView extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            paymentViewLoaded: false
        };
    }

    componentDidMount() {
        // To initialize the component, you'll need call the component's initialize method with your
        // backend's session token and a return URL for your application. 
        // 
        // This should occur at some point when the payment view is added to your application's view, 
        // but it should only be repeated if initialization fails.
        this.refs['my_ref'].initialize('my_session_token', 'my_apps_return_url')
    }

    onInitialized = () => {
        // Once the view is initialized, you can render content into it.
        this.refs['my_ref'].load()
    }

    onLoaded = () => {
        // Once the view is loaded, the user should be able to see the payment method. They can then
        // choose to use it (it's up to you to determine how that is recognized) and tap a "buy-like"
        // button.
        this.setState({paymentViewLoaded: true})
    }

    buyButtonPressed = () => {
        // When the button is tapped, call authorize() on the view.
        this.refs['my_ref'].authorize()
    }

    onAuthorized = (event) => {
        // If successfully authorized, the authorization token can be used by your backend to create
        // an order. 
        // 
        // You can also load a payment review view to allow the user to evaluate their
        // payment choice. 
        let params = event.nativeEvent

        if (params.authorized) {
            submitAuthToken(params.authToken)
        }
    }

    render() {
        return(
            // Other parts of the view
            // ...
            // The payment view
            <KlarnaPaymentView
                category={'pay_later'}
                ref={'my_ref'}
                onInitialized={this.onInitialized}
                onLoaded={this.onLoaded}
                onAuthorized={this.onAuthorized} />
            // ...
            // Your buy button
            <Button 
                disabled={!this.state.paymentViewLoaded}
                onPress={this.buyButtonPressed} />
        );
    }
}

Contributing

Support

If you are having any issues using the SDK in your project or if you think that something is wrong with the SDK itself, please create an issue on Github or report a bug by following the guidelines in the next section.

How can I contribute?

Thank you for reading this and taking time to contribute to React Native Klarna In-App SDK! Below is a set of guidelines to help you contribute whether you want to report a bug, come with suggestions or modify code.

Reporting Bugs

This section will guide you through submitting a bug report for Klarna In-App SDK.

Before submitting a bug report, please check that the issue hasn’t been reported before. If you find a Closed issue that seem to describe an issue that is similar to what you want to report, open a new issue and link to the original issue in the new one. When you have checked that the issue hasn’t been reported before fill out the required template which will help us resolve the issue faster.

Submitting a Bug Report

Bugs that are submitted are tracked as GitHub issues. To report a bug, create an issue and use the template to provide information about the bug. Explain the problem thoroughly and include any additional information that you think might help the maintainers reproduce the issue. When creating the GitHub issue please make sure that you:

  • Use a clear and descriptive title for the issue.
  • Describe the exact steps which reproduce the problem with as many details as possible. It’s generally better to provide too much than too little information.
  • Describe the behavior you observed after following the steps and explain exactly what the problem is with that behavior.
  • Explain which behavior you expected instead and why.
  • Provide screenshots and/or screen recordings that might help explain the issue you are facing. To screen record a phone connected to Android Studio or an emulator follow the steps here. To screen record on iOS follow the steps described here.
  • Include relevant logs in the bug report by putting it in a code block, a file attachment or in a gist and provide a link to that gist.
  • Tell how recently you started having the issue. When was the first time you experienced the issue and was it after updating the SDK version? Or has it always been a problem?
  • If the problem started happening recently, can you reproduce it in an older version of the SDK? What’s the most recent version in which the problem doesn’t happen?
  • Can you reliably reproduce the issue? If not, explain how often it occurs and under what conditions it normally happens. For example in what environment you are running.

Include details about the device/emulator/simulator you are experiencing the issue on:

  • Which version of the SDK are you using?
  • Which OS is this a problem in, iOS, Android or both? What version(s)? Also add the appropriate label to the issue.
  • Did you experience the issue in simulator/emulator or on real device(s)?
Contributing with Code

Before contributing please read through the Klarna In-App SDK documentation.

Branching

Prefix the branch you are going to work on depending on what you are working on (bug fix or feature). Use the following prefixes when creating a new branch:

  • feature/ if the branch contains a new feature, example: feature/my-shiny-feature.
  • bugfix/ if the branch contains a bug fix, example: bugfix/my-bug-fix.
Pull Requests

When creating a PR include as much information as possible about the type of enhancement, whether if it’s a bugfix, new functionality or any other change. There’s a template for you to fill out which will make the review process for the maintainers faster. When creating a PR do it against the master branch. The PR should include:

  • A clear and descriptive title.
  • Description of the issue if you are fixing a bug together with a link to the relevant issue or background for introducing a new feature.

Download Details:

Author: klarna

Source Code: https://github.com/klarna/react-native-klarna-inapp-sdk

#react-native #react #mobile-apps

What is GEEK

Buddha Community

React Native Klarna In-App SDK
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Top 10 React Native App Development Companies in USA

React Native is the most popular dynamic framework that provides the opportunity for Android & iOS users to download and use your product. Finding a good React Native development company is incredibly challenging. Use our list as your go-to resource for React Native app development Companies in USA.

List of Top-Rated React Native Mobile App Development Companies in USA:

  1. AppClues Infotech
  2. WebClues Infotech
  3. AppClues Studio
  4. WebClues Global
  5. Data EximIT
  6. Apptunix
  7. BHW Group
  8. Willow Tree:
  9. MindGrub
  10. Prismetric

A Brief about the company details mentioned below:

1. AppClues Infotech
As a React Native Mobile App Development Company in USA, AppClues Infotech offers user-centered mobile app development for iOS & Android. Since their founding in 2014, their React Native developers create beautiful mobile apps.

They have a robust react native app development team that has high knowledge and excellent strength of developing any type of mobile app. They have successfully delivered 450+ mobile apps as per client requirements and functionalities.
Website: https://www.appcluesinfotech.com/

2. WebClues Infotech
WebClues Infotech is the Top-Notch React Native mobile app development company in USA & offering exceptional service worldwide. Since their founding in 2014, they have completed 950+ web & mobile apps projects on time.

They have the best team of developers who has an excellent knowledge of developing the most secure, robust & Powerful React Native Mobile Apps. From start-ups to enterprise organizations, WebClues Infotech provides top-notch React Native App solutions that meet the needs of their clients.
Website: https://www.webcluesinfotech.com/

3. AppClues Studio
AppClues Studio is one of the top React Native mobile app development company in USA and offers the best service worldwide at an affordable price. They have a robust & comprehensive team of React Native App developers who has high strength & extensive knowledge of developing any type of mobile apps.
Website: https://www.appcluesstudio.com/

4. WebClues Global
WebClues Global is one of the best React Native Mobile App Development Company in USA. They provide low-cost & fast React Native Development Services and their React Native App Developers have a high capability of serving projects on more than one platform.

Since their founding in 2014, they have successfully delivered 721+ mobile app projects accurately. They offer versatile React Native App development technology solutions to their clients at an affordable price.
Website: https://www.webcluesglobal.com/

5. Data EximIT
Hire expert React Native app developer from top React Native app development company in USA. Data EximIT is providing high-quality and innovative React Native application development services and support for your next projects. The company has been in the market for more than 8 years and has already gained the trust of 553+ clients and completed 1250+ projects around the globe.

They have a large pool of React Native App developers who can create scalable, full-fledged, and appealing mobile apps to meet the highest industry standards.
Website: https://www.dataeximit.com/

6. Apptunix
Apptunix is the best React Native App Development Company in the USA. It was established in 2013 and vast experience in developing React Native apps. After developing various successful React Native Mobile Apps, the company believes that this technology helps them incorporate advanced features in mobile apps without influencing the user experience.
Website: https://www.apptunix.com/

7. BHW Group
BHW Group is a Top-Notch React Native Mobile App Development Company in the USA. The company has 13+ years of experience in providing qualitative app development services to clients worldwide. They have a compressive pool of React Native App developers who can create scalable, full-fledged, and creative mobile apps to meet the highest industry standards.
Website: https://thebhwgroup.com/

8. Willow Tree:
Willow Tree is the Top-Notch React Native Mobile App Development Company in the USA & offering exceptional React Native service. They have the best team of developers who has an excellent knowledge of developing the most secure, robust & Powerful React Native Mobile Apps. From start-ups to enterprise organizations, Willow Tree has top-notch React Native App solutions that meet the needs of their clients.
Website: https://willowtreeapps.com/

9. MindGrub
MindGrub is a leading React Native Mobile App Development Company in the USA. Along with React Native, the company also works on other emerging technologies like robotics, augmented & virtual reality. The Company has excellent strength and the best developers team for any type of React Native mobile apps. They offer versatile React Native App development technology solutions to their clients.
Website: https://www.mindgrub.com/

10. Prismetric
Prismetric is the premium React Native Mobile App Development Company in the USA. They provide fast React Native Development Services and their React Native App Developers have a high capability of serving projects on various platforms. They focus on developing customized solutions for specific business requirements. Being a popular name in the React Native development market, Prismetric has accumulated a specialty in offering these services.
Website: https://www.prismetric.com/

#top rated react native app development companies in usa #top 10 react native app development companies in usa #top react native app development companies in usa #react native app development technologies #react native app development #hire top react native app developers in usa

Hire Top-Notch React Native App Developers in USA

Do you want to hire talented & highly skilled React Native mobile app developers in USA? AppClues Infotech has the best team of dedicated React Native App designers & developers that provide the complete React Native solution & listed the top-notch USA-based companies list for your kind information.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#hire best react native app developers in usa #hire react native mobile app developers #top react native development companies #top react native app development company in usa #best react native app development services provider company #custom react native app development company

Top Rated React Native Development Agency

AppClues Infotech is a premier & leading React Native app Development Company in USA having highly skilled React Native app developers offering robust services with the latest technology & functionalities.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#react native app development company #top react native app development company in usa #best react native app development services usa #react native mobile development #react native mobile development #top react native app development companies usa

React Native Mobile App Development

React Native is a framework that allows you to build mobile applications for both Android and iOS platforms using a similar codebase. This can shorten the development time and reduce the overall cost of building mobile apps.

Looking to create Mobile Applications but low in the budget? Contact Skenix Infotech now to get the most effective React Native Mobile App Development Services.

#react native development #mobile app development #react native ios app #react native ui #react native mobile app #react native