Giter Club home page Giter Club logo

react-native-idfa's Introduction

react-native-idfa

Retrieve the advertising identifier across ios and android on react-native with this small library. Support RN > 0.56 with or without and cocoapods

Build Status npm version npm downloads

How to install

npm install react-native-idfa
react-native link

Since this library is using the advertising identifier, you must remember to add AdSupport in your IOS project.

If you're using Cocoapods, there is no need to this as when you're adding react-native-idfa to your Podfile it will get added by default

Podfile

  pod 'react-native-idfa',  path: '../node_modules/react-native-idfa'

Add AdSupport.framework under "Link Binary With Libraries".

How to use!

import { IDFA } from 'react-native-idfa';

class Basic extends Component {
  state = {
     IDFA: '',
  };

  componentDidMount() {
    IDFA.getIDFA().then((idfa) => {
      this.setState({ IDFA: idfa, });
    })
    .catch((e) => {
      console.error(e);
    });
  }

  render() {
    return (
      <View style={{ flex: 1 }}>
        <Text>Your IDFA is : {this.state.IDFA}</Text>
      </View>
    );
  }
}

Changing react-native-idfa's com.google.android.gms:play-services-ads version

In your build.gradle make sure to force the version to whatever version makes sense through our your dependencies

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            // If different projects require different versions of
            // Google Play Services it causes a crash on run.
            // Fix by overriding version for all projects.
            details.useVersion('17.0.0')
        }
    }
}

Known flaws

Since this is a react-native repository we will ship the code untranspiled and with flow types along it.

Using gms 17.0.0

Google has introduced some breaking changes on 17.0.0. The SDK will throw an error if your manifest.xml is not configured properly

    ******************************************************************************
    * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
    * should follow the instructions here: https://goo.gl/fQ2neu to add a valid  *
    * App ID inside the AndroidManifest. Google Ad Manager publishers should     *
    * follow instructions here: https://goo.gl/h17b6x.                           *
    ******************************************************************************

update your manifest.xml
Google's Ad Manager guide

<manifest>
    <application>
        <meta-data
            android:name="com.google.android.gms.ads.AD_MANAGER_APP"
            android:value="true"/>
    </application>
</manifest>

react-native-idfa's People

Contributors

ptomasroos avatar virtim avatar ahmetsozkesen avatar kelion avatar mikaoelitiana avatar rpavlovs avatar haikov avatar t0m0120 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.