react-native-play-install-referrer
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -0,1 +1,11 @@ | ||
### Version 1.1.8 [19th January 2022] | ||
#### Added | ||
- Added example app in TypeScript. | ||
#### Changed | ||
- Updated TypeScript definition for callback. (thanks to @apfritts) | ||
- Ignored this module on non-Android platforms. (thanks to @apfritts) | ||
--- | ||
### Version 1.1.7 [20th October 2021] | ||
@@ -6,3 +16,3 @@ #### Changed | ||
#### Fixed | ||
- Fixed `addListener` and `removeListeners` warnings ([same issue](https://github.com/react-native-netinfo/react-native-netinfo/issues/486) with [suggested fix](https://github.com/software-mansion/react-native-reanimated/pull/2316/files) which got copy pasted in this plugin as well). Thanks to @mikehardy. | ||
- Fixed `addListener` and `removeListeners` warnings ([same issue](https://github.com/react-native-netinfo/react-native-netinfo/issues/486) with [suggested fix](https://github.com/software-mansion/react-native-reanimated/pull/2316/files) which got copy pasted in this plugin as well). (thanks to @mikehardy) | ||
@@ -9,0 +19,0 @@ --- |
@@ -6,9 +6,28 @@ // | ||
// Created by Uglješa Erceg (@uerceg) on 24th April 2020. | ||
// Copyright (c) 2021 uerceg. All rights reserved. | ||
// Copyright (c) 2021-2022 uerceg. All rights reserved. | ||
// | ||
declare module 'react-native-play-install-referrer' { | ||
export class PlayInstallReferrerError extends Error { | ||
responseCode: string | ||
} | ||
export type PlayInstallReferrerInfo = { | ||
googlePlayInstant: boolean | ||
installBeginTimestampSeconds: string | ||
installBeginTimestampServerSeconds: string | ||
installReferrer: string | ||
installVersion: string | ||
referrerClickTimestampSeconds: string | ||
referrerClickTimestampServerSeconds: string | ||
} | ||
export type PlayInstallReferrerCallback = ( | ||
info: PlayInstallReferrerInfo | null, | ||
error: PlayInstallReferrerError | null, | ||
) => void | ||
export const PlayInstallReferrer: { | ||
getInstallReferrerInfo: (callback) => void | ||
getInstallReferrerInfo: (callback: PlayInstallReferrerCallback) => void | ||
} | ||
} |
69
index.js
// | ||
// index.js | ||
// play-install-referrer-react-native | ||
// version: 1.1.7 | ||
// version: 1.1.8 | ||
// | ||
// Created by Uglješa Erceg (@uerceg) on 24th April 2020. | ||
// Copyright (c) 2020 uerceg. All rights reserved. | ||
// Copyright (c) 2020-2021 uerceg. All rights reserved. | ||
// | ||
@@ -12,39 +12,44 @@ | ||
import { | ||
import { | ||
NativeModules, | ||
NativeEventEmitter, | ||
Platform, | ||
} from 'react-native'; | ||
let modulePlayInstallReferrer = NativeModules.PlayInstallReferrer; | ||
let modulePlayInstallReferrerEmitter = new NativeEventEmitter(NativeModules.PlayInstallReferrer); | ||
var PlayInstallReferrer = {}; | ||
PlayInstallReferrer.getInstallReferrerInfo = function(callback) { | ||
// subscribe to get play install referrer value if successfully read | ||
const subscriptionValue = modulePlayInstallReferrerEmitter.addListener('play_install_referrer_value', (playInstallReferrerValue) => { | ||
callback(playInstallReferrerValue, null); | ||
// clean up subscriptions if they exist | ||
if (subscriptionValue != null) { | ||
subscriptionValue.remove(); | ||
} | ||
if (subscriptionError != null) { | ||
subscriptionError.remove(); | ||
} | ||
}); | ||
// subscribe to get error in case play install referrer value reading failed | ||
const subscriptionError = modulePlayInstallReferrerEmitter.addListener('play_install_referrer_error', (error) => { | ||
callback(null, error); | ||
// clean up subscriptions if they exist | ||
if (subscriptionValue != null) { | ||
subscriptionValue.remove(); | ||
} | ||
if (subscriptionError != null) { | ||
subscriptionError.remove(); | ||
} | ||
}); | ||
// invoke native API | ||
modulePlayInstallReferrer.getInstallReferrerInfo(); | ||
}; | ||
if (Platform.OS === 'android') { | ||
let modulePlayInstallReferrer = NativeModules.PlayInstallReferrer; | ||
let modulePlayInstallReferrerEmitter = new NativeEventEmitter(NativeModules.PlayInstallReferrer); | ||
PlayInstallReferrer.getInstallReferrerInfo = function (callback) { | ||
// subscribe to get play install referrer value if successfully read | ||
const subscriptionValue = modulePlayInstallReferrerEmitter.addListener('play_install_referrer_value', (playInstallReferrerValue) => { | ||
callback(playInstallReferrerValue, null); | ||
// clean up subscriptions if they exist | ||
if (subscriptionValue != null) { | ||
subscriptionValue.remove(); | ||
} | ||
if (subscriptionError != null) { | ||
subscriptionError.remove(); | ||
} | ||
}); | ||
// subscribe to get error in case play install referrer value reading failed | ||
const subscriptionError = modulePlayInstallReferrerEmitter.addListener('play_install_referrer_error', (error) => { | ||
callback(null, error); | ||
// clean up subscriptions if they exist | ||
if (subscriptionValue != null) { | ||
subscriptionValue.remove(); | ||
} | ||
if (subscriptionError != null) { | ||
subscriptionError.remove(); | ||
} | ||
}); | ||
// invoke native API | ||
modulePlayInstallReferrer.getInstallReferrerInfo(); | ||
}; | ||
} else { | ||
PlayInstallReferrer.getInstallReferrerInfo = function () {}; | ||
} | ||
module.exports = { PlayInstallReferrer } |
{ | ||
"name": "react-native-play-install-referrer", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Play Install Referrer Library wrapper for React Native", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/ugi/play-install-referrer-react-native.git" | ||
"url": "git+https://github.com/uerceg/play-install-referrer-react-native.git" | ||
}, | ||
@@ -22,5 +22,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/ugi/play-install-referrer-react-native/issues" | ||
"url": "https://github.com/uerceg/play-install-referrer-react-native/issues" | ||
}, | ||
"homepage": "https://github.com/ugi/play-install-referrer-react-native" | ||
"homepage": "https://github.com/uerceg/play-install-referrer-react-native" | ||
} |
@@ -10,3 +10,3 @@ # Play Install Referrer Library wrapper for React Native | ||
<td align="left">Current version:</td> | ||
<td align="left"><a href=../../releases/tag/v1.1.7><b>1.1.7</b></a></td> | ||
<td align="left"><a href=../../releases/tag/v1.1.8><b>1.1.8</b></a></td> | ||
</tr> | ||
@@ -94,6 +94,6 @@ <tr> | ||
You can find example app using **react-native-play-install-referrer** plugin inside [**app**](./app) folder of this repository. In case you want to run the app (with re-adding plugin), you can run this command **inside app folder**: | ||
You can find example apps using **react-native-play-install-referrer** plugin inside [**example-app-js**](./example-app-js) and [**example-app-ts**](./example-app-ts) folders of this repository. In case you want to run the app (with re-adding plugin), you can run this command **inside app folder**: | ||
``` | ||
yarn remove react-native-play-install-referrer && yarn add ../ && react-native run-android | ||
yarn remove react-native-play-install-referrer && yarn add ../ && npx react-native run-android | ||
``` | ||
@@ -100,0 +100,0 @@ |
@@ -9,3 +9,4 @@ # Security Policy | ||
| ------- | ------------------ | | ||
| 1.1.7 | :white_check_mark: | | ||
| 1.1.8 | :white_check_mark: | | ||
| 1.1.7 | :x: | | ||
| 1.1.6 | :x: | | ||
@@ -12,0 +13,0 @@ | 1.1.5 | :x: | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28659
76