expo-ads-facebook
Advanced tools
Comparing version 10.1.2 to 11.0.0
import React from 'react'; | ||
import { View } from 'react-native'; | ||
declare type Props = React.ComponentProps<typeof View>; | ||
declare type Props = React.ComponentPropsWithRef<typeof View>; | ||
export default class AdIconView extends React.Component<Props> { | ||
@@ -8,3 +8,3 @@ render(): JSX.Element; | ||
export declare type NativeAdIconView = React.Component<Props>; | ||
export declare const NativeAdIconView: React.ComponentType<any>; | ||
export declare const NativeAdIconView: React.ComponentType<Props>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
import nullthrows from 'nullthrows'; | ||
@@ -9,3 +9,3 @@ import React from 'react'; | ||
const context = nullthrows(contextValue); | ||
return React.createElement(NativeAdIconView, Object.assign({}, this.props, { ref: context.nativeRef })); | ||
return React.createElement(NativeAdIconView, { ...this.props, ref: context.nativeRef }); | ||
})); | ||
@@ -12,0 +12,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function AdIconView() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'AdIconView'); |
import React from 'react'; | ||
import { View } from 'react-native'; | ||
declare type Props = React.ComponentProps<typeof View>; | ||
declare type Props = React.ComponentPropsWithRef<typeof View>; | ||
export default class AdMediaView extends React.Component<Props> { | ||
@@ -8,3 +8,3 @@ render(): JSX.Element; | ||
export declare type NativeAdMediaView = React.Component<Props>; | ||
export declare const NativeAdMediaView: React.ComponentType<any>; | ||
export declare const NativeAdMediaView: React.ComponentType<Props>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
import nullthrows from 'nullthrows'; | ||
@@ -9,3 +9,3 @@ import React from 'react'; | ||
const context = nullthrows(contextValue); | ||
return React.createElement(NativeAdMediaView, Object.assign({}, this.props, { ref: context.nativeRef })); | ||
return React.createElement(NativeAdMediaView, { ...this.props, ref: context.nativeRef }); | ||
})); | ||
@@ -12,0 +12,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function AdMediaView() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'AdMediaView'); |
import React from 'react'; | ||
import { View } from 'react-native'; | ||
declare type Props = React.ComponentProps<typeof View> & { | ||
declare type Props = React.ComponentPropsWithRef<typeof View> & { | ||
iconSize: number; | ||
@@ -5,0 +5,0 @@ iconColor?: string; |
@@ -1,2 +0,2 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
import nullthrows from 'nullthrows'; | ||
@@ -12,6 +12,7 @@ import React from 'react'; | ||
export default class AdOptionsView extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.shouldAlignHorizontal = () => this.props.orientation === 'horizontal'; | ||
} | ||
static defaultProps = { | ||
iconSize: 23, | ||
orientation: 'horizontal', | ||
}; | ||
shouldAlignHorizontal = () => this.props.orientation === 'horizontal'; | ||
render() { | ||
@@ -38,12 +39,8 @@ const style = this.shouldAlignHorizontal() | ||
const adViewRef = nullthrows(contextValue && contextValue.nativeAdViewRef); | ||
return (React.createElement(NativeAdOptionsView, Object.assign({}, props, platformSpecificProps, { style: [this.props.style, style], nativeAdViewTag: findNodeHandle(adViewRef.current) }))); | ||
return (React.createElement(NativeAdOptionsView, { ...props, ...platformSpecificProps, style: [this.props.style, style], nativeAdViewTag: findNodeHandle(adViewRef.current) })); | ||
})); | ||
} | ||
} | ||
AdOptionsView.defaultProps = { | ||
iconSize: 23, | ||
orientation: 'horizontal', | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/no-redeclare -- the type and variable share a name | ||
export const NativeAdOptionsView = requireNativeViewManager('AdOptionsView'); | ||
//# sourceMappingURL=AdOptionsView.js.map |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function AdIconView() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'AdOptionsView'); |
@@ -1,4 +0,6 @@ | ||
import { PermissionResponse, PermissionStatus, PermissionExpiration } from 'expo-modules-core'; | ||
import { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions } from 'expo-modules-core'; | ||
export declare type AdLogLevel = 'none' | 'debug' | 'verbose' | 'warning' | 'error' | 'notification'; | ||
export { PermissionResponse, PermissionStatus, PermissionExpiration }; | ||
export { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions }; | ||
declare function requestPermissionsAsync(): Promise<PermissionResponse>; | ||
declare function getPermissionsAsync(): Promise<PermissionResponse>; | ||
declare const _default: { | ||
@@ -9,4 +11,5 @@ /** | ||
readonly currentDeviceHash: string; | ||
requestPermissionsAsync(): Promise<PermissionResponse>; | ||
getPermissionsAsync(): Promise<PermissionResponse>; | ||
requestPermissionsAsync: typeof requestPermissionsAsync; | ||
getPermissionsAsync: typeof getPermissionsAsync; | ||
usePermissions: (options?: PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>]; | ||
/** | ||
@@ -13,0 +16,0 @@ * Sets whether Facebook SDK should enable advertising tracking. |
@@ -1,3 +0,2 @@ | ||
import { NativeModulesProxy, UnavailabilityError } from '@unimodules/core'; | ||
import { PermissionStatus } from 'expo-modules-core'; | ||
import { PermissionStatus, createPermissionHook, NativeModulesProxy, UnavailabilityError, } from 'expo-modules-core'; | ||
import { Platform } from 'react-native'; | ||
@@ -12,2 +11,34 @@ const { CTKAdSettingsManager } = NativeModulesProxy; | ||
}; | ||
async function requestPermissionsAsync() { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.requestPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'requestPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.requestPermissionsAsync(); | ||
} | ||
async function getPermissionsAsync() { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.getPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'getPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.getPermissionsAsync(); | ||
} | ||
// @needsAudit | ||
/** | ||
* Check or request permissions for ad settings. | ||
* This uses both `requestPermissionAsync` and `getPermissionsAsync` to interact with the permissions. | ||
* | ||
* @example | ||
* ```ts | ||
* const [status, requestPermission] = AdSettings.usePermissions(); | ||
* ``` | ||
*/ | ||
const usePermissions = createPermissionHook({ | ||
getMethod: getPermissionsAsync, | ||
requestMethod: requestPermissionsAsync, | ||
}); | ||
// TODO: rewrite the docblocks | ||
@@ -21,20 +52,5 @@ export default { | ||
}, | ||
async requestPermissionsAsync() { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.requestPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'requestPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.requestPermissionsAsync(); | ||
}, | ||
async getPermissionsAsync() { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.getPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'getPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.getPermissionsAsync(); | ||
}, | ||
requestPermissionsAsync, | ||
getPermissionsAsync, | ||
usePermissions, | ||
/** | ||
@@ -41,0 +57,0 @@ * Sets whether Facebook SDK should enable advertising tracking. |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function AdSettings() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'AdSettings'); |
@@ -6,6 +6,3 @@ import nullthrows from 'nullthrows'; | ||
export default class AdTriggerView extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this._trigger = null; | ||
} | ||
_trigger = null; | ||
render() { | ||
@@ -50,5 +47,5 @@ return (React.createElement(AdTriggerViewContext.Consumer, null, (contextValue) => { | ||
_renderDefaultInteractiveComponent(props) { | ||
return React.createElement(TouchableOpacity, Object.assign({}, props, { collapsable: false })); | ||
return React.createElement(TouchableOpacity, { ...props, collapsable: false }); | ||
} | ||
} | ||
//# sourceMappingURL=AdTriggerView.js.map |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function AdTriggerView() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'AdTriggerView'); |
@@ -1,2 +0,2 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
import React from 'react'; | ||
@@ -7,3 +7,3 @@ export default class BannerAd extends React.Component { | ||
const size = _getSizeForAdType(type); | ||
return (React.createElement(NativeBannerView, Object.assign({ size: size, onAdPress: onPress, onAdError: onError, style: [style, { height: size }] }, props))); | ||
return (React.createElement(NativeBannerView, { size: size, onAdPress: onPress, onAdError: onError, style: [style, { height: size }], ...props })); | ||
} | ||
@@ -10,0 +10,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function BannerAd() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'BannerAd'); |
@@ -1,2 +0,2 @@ | ||
import { NativeModulesProxy } from '@unimodules/core'; | ||
import { NativeModulesProxy } from 'expo-modules-core'; | ||
const { CTKInterstitialAdManager = { | ||
@@ -3,0 +3,0 @@ async showAd() { |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter as NativeEventEmitter, NativeModulesProxy } from '@unimodules/core'; | ||
import { EventEmitter as NativeEventEmitter, NativeModulesProxy } from 'expo-modules-core'; | ||
import { EventEmitter } from 'fbemitter'; | ||
@@ -8,2 +8,16 @@ const { CTKNativeAdManager } = NativeModulesProxy; | ||
class NativeAdsManager { | ||
/** {@string} with placement id of ads **/ | ||
placementId; | ||
/** {@number} of ads to request at once **/ | ||
adsToRequest; | ||
/** {@boolean} indicating whether AdsManager is ready to serve ads **/ | ||
isValid = false; | ||
/** {@EventEmitter} used for sending out updates **/ | ||
eventEmitter = new EventEmitter(); | ||
static async registerViewsForInteractionAsync(nativeAdViewTag, mediaViewTag, adIconViewTag, clickable) { | ||
return await CTKNativeAdManager.registerViewsForInteraction(nativeAdViewTag, mediaViewTag, adIconViewTag, clickable); | ||
} | ||
static triggerEvent(nativeAdViewTag) { | ||
return CTKNativeAdManager.triggerEvent(nativeAdViewTag); | ||
} | ||
/** | ||
@@ -16,6 +30,2 @@ * Creates an instance of AdsManager with a given placementId and adsToRequest. | ||
constructor(placementId, adsToRequest = 10) { | ||
/** {@boolean} indicating whether AdsManager is ready to serve ads **/ | ||
this.isValid = false; | ||
/** {@EventEmitter} used for sending out updates **/ | ||
this.eventEmitter = new EventEmitter(); | ||
this.placementId = placementId; | ||
@@ -26,8 +36,2 @@ this.adsToRequest = adsToRequest; | ||
} | ||
static async registerViewsForInteractionAsync(nativeAdViewTag, mediaViewTag, adIconViewTag, clickable) { | ||
return await CTKNativeAdManager.registerViewsForInteraction(nativeAdViewTag, mediaViewTag, adIconViewTag, clickable); | ||
} | ||
static triggerEvent(nativeAdViewTag) { | ||
return CTKNativeAdManager.triggerEvent(nativeAdViewTag); | ||
} | ||
/** | ||
@@ -34,0 +38,0 @@ * Listens for AdManager state changes and updates internal state. When it changes, |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
// TODO: Bacon: Maybe add static functions | ||
@@ -3,0 +3,0 @@ export default function NativeAdsManager() { |
@@ -27,3 +27,3 @@ import React from 'react'; | ||
}) => void; | ||
} & React.ComponentProps<typeof View>; | ||
} & React.ComponentPropsWithRef<typeof View>; | ||
declare type NativeAdView = React.Component<NativeAdViewProps>; | ||
@@ -30,0 +30,0 @@ declare const NativeAdView: React.ComponentType<any>; |
@@ -1,2 +0,2 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
import nullthrows from 'nullthrows'; | ||
@@ -16,60 +16,11 @@ import React from 'react'; | ||
return class NativeAdContainer extends React.Component { | ||
_readySubscription = null; | ||
_errorSubscription = null; | ||
_nativeAdViewRef = React.createRef(); | ||
_adMediaViewNodeHandle = null; | ||
_adIconViewNodeHandle = null; | ||
_interactiveTriggerNodeHandles = new Map(); | ||
state; | ||
constructor(props) { | ||
super(props); | ||
this._readySubscription = null; | ||
this._errorSubscription = null; | ||
this._nativeAdViewRef = React.createRef(); | ||
this._adMediaViewNodeHandle = null; | ||
this._adIconViewNodeHandle = null; | ||
this._interactiveTriggerNodeHandles = new Map(); | ||
this._handleAdLoaded = ({ nativeEvent: ad }) => { | ||
this.setState({ ad }, () => { | ||
if (this.props.onAdLoaded) { | ||
const ad = nullthrows(this.state.ad); | ||
this.props.onAdLoaded(ad); | ||
} | ||
}); | ||
}; | ||
this._adMediaViewContextValue = { | ||
nativeRef: (component) => { | ||
if (component) { | ||
this._setAdNodeHandles({ adMediaViewNodeHandle: nullthrows(findNodeHandle(component)) }); | ||
} | ||
else { | ||
this._setAdNodeHandles({ adMediaViewNodeHandle: null }); | ||
} | ||
}, | ||
}; | ||
this._adOptionsViewContextValue = { | ||
nativeAdViewRef: this._nativeAdViewRef, | ||
}; | ||
this._adIconViewContextValue = { | ||
nativeRef: (component) => { | ||
if (component) { | ||
this._setAdNodeHandles({ adIconViewNodeHandle: nullthrows(findNodeHandle(component)) }); | ||
} | ||
else { | ||
this._setAdNodeHandles({ adIconViewNodeHandle: null }); | ||
} | ||
}, | ||
}; | ||
this._adTriggerViewContextValue = { | ||
registerComponent: (component) => { | ||
const nodeHandle = nullthrows(findNodeHandle(component)); | ||
const interactiveTriggerNodeHandles = new Map(this._interactiveTriggerNodeHandles); | ||
interactiveTriggerNodeHandles.set(component, nodeHandle); | ||
this._setAdNodeHandles({ interactiveTriggerNodeHandles }); | ||
}, | ||
unregisterComponent: (component) => { | ||
const interactiveTriggerNodeHandles = new Map(this._interactiveTriggerNodeHandles); | ||
interactiveTriggerNodeHandles.delete(component); | ||
this._setAdNodeHandles({ interactiveTriggerNodeHandles }); | ||
}, | ||
onTriggerAd: () => { | ||
if (this._adMediaViewNodeHandle !== null && Platform.OS === 'android') { | ||
const nodeHandle = findNodeHandle(this._nativeAdViewRef.current); | ||
AdsManager.triggerEvent(nodeHandle); | ||
} | ||
}, | ||
}; | ||
this.state = { | ||
@@ -87,3 +38,3 @@ ad: null, | ||
} | ||
this._errorSubscription = this.props.adsManager.onAdsErrored(error => { | ||
this._errorSubscription = this.props.adsManager.onAdsErrored((error) => { | ||
// From what I, @sjchmiela, understand, an error may be encountered multiple times | ||
@@ -120,3 +71,3 @@ // and it does *not* mean that the manager is not able to request ads at all - | ||
React.createElement(AdTriggerViewContext.Provider, { value: this._adTriggerViewContextValue }, | ||
React.createElement(AdOptionsViewContext.Provider, { value: this._adOptionsViewContextValue }, this.state.ad ? React.createElement(Component, Object.assign({}, props, { nativeAd: this.state.ad })) : null)))))); | ||
React.createElement(AdOptionsViewContext.Provider, { value: this._adOptionsViewContextValue }, this.state.ad ? React.createElement(Component, { ...props, nativeAd: this.state.ad }) : null)))))); | ||
if (NativeAdLayout) { | ||
@@ -131,2 +82,52 @@ return React.createElement(NativeAdLayout, null, viewHierarchy); | ||
} | ||
_handleAdLoaded = ({ nativeEvent: ad }) => { | ||
this.setState({ ad }, () => { | ||
if (this.props.onAdLoaded) { | ||
const ad = nullthrows(this.state.ad); | ||
this.props.onAdLoaded(ad); | ||
} | ||
}); | ||
}; | ||
_adMediaViewContextValue = { | ||
nativeRef: (component) => { | ||
if (component) { | ||
this._setAdNodeHandles({ adMediaViewNodeHandle: nullthrows(findNodeHandle(component)) }); | ||
} | ||
else { | ||
this._setAdNodeHandles({ adMediaViewNodeHandle: null }); | ||
} | ||
}, | ||
}; | ||
_adOptionsViewContextValue = { | ||
nativeAdViewRef: this._nativeAdViewRef, | ||
}; | ||
_adIconViewContextValue = { | ||
nativeRef: (component) => { | ||
if (component) { | ||
this._setAdNodeHandles({ adIconViewNodeHandle: nullthrows(findNodeHandle(component)) }); | ||
} | ||
else { | ||
this._setAdNodeHandles({ adIconViewNodeHandle: null }); | ||
} | ||
}, | ||
}; | ||
_adTriggerViewContextValue = { | ||
registerComponent: (component) => { | ||
const nodeHandle = nullthrows(findNodeHandle(component)); | ||
const interactiveTriggerNodeHandles = new Map(this._interactiveTriggerNodeHandles); | ||
interactiveTriggerNodeHandles.set(component, nodeHandle); | ||
this._setAdNodeHandles({ interactiveTriggerNodeHandles }); | ||
}, | ||
unregisterComponent: (component) => { | ||
const interactiveTriggerNodeHandles = new Map(this._interactiveTriggerNodeHandles); | ||
interactiveTriggerNodeHandles.delete(component); | ||
this._setAdNodeHandles({ interactiveTriggerNodeHandles }); | ||
}, | ||
onTriggerAd: () => { | ||
if (this._adMediaViewNodeHandle !== null && Platform.OS === 'android') { | ||
const nodeHandle = findNodeHandle(this._nativeAdViewRef.current); | ||
AdsManager.triggerEvent(nodeHandle); | ||
} | ||
}, | ||
}; | ||
/** | ||
@@ -133,0 +134,0 @@ * Updates the registered ad views given their node handles. The node handles are not stored in |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
export default function withNativeAd() { | ||
@@ -3,0 +3,0 @@ throw new UnavailabilityError('expo-ads-facebook', 'withNativeAd'); |
@@ -13,10 +13,21 @@ # Changelog | ||
## 10.1.2 — 2021-06-24 | ||
## 11.0.0 — 2021-09-28 | ||
_This version does not introduce any user-facing changes._ | ||
### 🛠 Breaking changes | ||
## 10.1.1 — 2021-06-22 | ||
- Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach)) | ||
_This version does not introduce any user-facing changes._ | ||
### 🎉 New features | ||
- Add `usePermissions` hooks from modules factory. ([#13850](https://github.com/expo/expo/pull/13850) by [@bycedric](https://github.com/bycedric)) | ||
### 🐛 Bug fixes | ||
- Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo)) | ||
### 💡 Others | ||
- Migrated from `@unimodules/core` to `expo-modules-core`. ([#13757](https://github.com/expo/expo/pull/13757) by [@tsapeta](https://github.com/tsapeta)) | ||
- Updated `@expo/config-plugins` ([#14443](https://github.com/expo/expo/pull/14443) by [@EvanBacon](https://github.com/EvanBacon)) | ||
## 10.1.0 — 2021-06-16 | ||
@@ -23,0 +34,0 @@ |
{ | ||
"name": "expo-ads-facebook", | ||
"version": "10.1.2", | ||
"version": "11.0.0", | ||
"description": "Facebook Audience SDK integration", | ||
@@ -32,6 +32,6 @@ "main": "build/index.js", | ||
"license": "MIT", | ||
"homepage": "https://docs.expo.io/versions/latest/sdk/facebook-ads/", | ||
"homepage": "https://docs.expo.dev/versions/latest/sdk/facebook-ads/", | ||
"dependencies": { | ||
"@expo/config-plugins": "^3.0.0", | ||
"expo-modules-core": "~0.2.0", | ||
"@expo/config-plugins": "^3.1.0", | ||
"expo-modules-core": "~0.4.0", | ||
"fbemitter": "^2.1.1", | ||
@@ -43,3 +43,3 @@ "nullthrows": "^1.1.0" | ||
}, | ||
"gitHead": "4fc9d282ff7ab2fa9040b775aeca7c30f5167b17" | ||
"gitHead": "1fffde73411ee7a642b98f1506a8de921805d52b" | ||
} |
@@ -5,3 +5,3 @@ "use strict"; | ||
const USER_TRACKING = 'This identifier will be used to deliver personalized ads to you.'; | ||
exports.withUserTrackingPermission = (config, { userTrackingPermission } = {}) => { | ||
const withUserTrackingPermission = (config, { userTrackingPermission } = {}) => { | ||
if (!config.ios) | ||
@@ -15,1 +15,2 @@ config.ios = {}; | ||
}; | ||
exports.withUserTrackingPermission = withUserTrackingPermission; |
@@ -10,3 +10,3 @@ "use strict"; | ||
*/ | ||
exports.withSKAdNetworkIdentifiers = (config, identifiers) => { | ||
const withSKAdNetworkIdentifiers = (config, identifiers) => { | ||
if (!config.ios) { | ||
@@ -36,1 +36,2 @@ config.ios = {}; | ||
}; | ||
exports.withSKAdNetworkIdentifiers = withSKAdNetworkIdentifiers; |
@@ -1,3 +0,10 @@ | ||
import { NativeModulesProxy, UnavailabilityError } from '@unimodules/core'; | ||
import { PermissionResponse, PermissionStatus, PermissionExpiration } from 'expo-modules-core'; | ||
import { | ||
PermissionResponse, | ||
PermissionStatus, | ||
PermissionExpiration, | ||
PermissionHookOptions, | ||
createPermissionHook, | ||
NativeModulesProxy, | ||
UnavailabilityError, | ||
} from 'expo-modules-core'; | ||
import { Platform } from 'react-native'; | ||
@@ -9,3 +16,3 @@ | ||
export { PermissionResponse, PermissionStatus, PermissionExpiration }; | ||
export { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions }; | ||
@@ -19,2 +26,39 @@ const androidPermissionsResponse: PermissionResponse = { | ||
async function requestPermissionsAsync(): Promise<PermissionResponse> { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.requestPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'requestPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.requestPermissionsAsync(); | ||
} | ||
async function getPermissionsAsync(): Promise<PermissionResponse> { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.getPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'getPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.getPermissionsAsync(); | ||
} | ||
// @needsAudit | ||
/** | ||
* Check or request permissions for ad settings. | ||
* This uses both `requestPermissionAsync` and `getPermissionsAsync` to interact with the permissions. | ||
* | ||
* @example | ||
* ```ts | ||
* const [status, requestPermission] = AdSettings.usePermissions(); | ||
* ``` | ||
*/ | ||
const usePermissions = createPermissionHook({ | ||
getMethod: getPermissionsAsync, | ||
requestMethod: requestPermissionsAsync, | ||
}); | ||
// TODO: rewrite the docblocks | ||
@@ -28,24 +72,5 @@ export default { | ||
}, | ||
async requestPermissionsAsync(): Promise<PermissionResponse> { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.requestPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'requestPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.requestPermissionsAsync(); | ||
}, | ||
async getPermissionsAsync(): Promise<PermissionResponse> { | ||
if (Platform.OS === 'android') { | ||
return Promise.resolve(androidPermissionsResponse); | ||
} | ||
if (!CTKAdSettingsManager.getPermissionsAsync) { | ||
throw new UnavailabilityError('expo-ads-facebook', 'getPermissionsAsync'); | ||
} | ||
return await CTKAdSettingsManager.getPermissionsAsync(); | ||
}, | ||
requestPermissionsAsync, | ||
getPermissionsAsync, | ||
usePermissions, | ||
/** | ||
@@ -52,0 +77,0 @@ * Sets whether Facebook SDK should enable advertising tracking. |
@@ -1,2 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { UnavailabilityError } from 'expo-modules-core'; | ||
@@ -3,0 +3,0 @@ export default function AdSettings() { |
@@ -1,2 +0,2 @@ | ||
import { NativeModulesProxy } from '@unimodules/core'; | ||
import { NativeModulesProxy } from 'expo-modules-core'; | ||
@@ -3,0 +3,0 @@ const { |
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
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
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
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
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
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
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
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
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
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
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
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
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
No website
QualityPackage does not have a website.
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
188100
1713
+ Addedcompare-versions@3.6.0(transitive)
+ Addedexpo-modules-core@0.4.10(transitive)
+ Addedinvariant@2.2.4(transitive)
- Removedexpo-modules-core@0.2.0(transitive)
Updated@expo/config-plugins@^3.1.0
Updatedexpo-modules-core@~0.4.0