Skip to content

Commit

Permalink
fix/cta_not_clickable_on_android (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
alhiwatan authored Oct 1, 2024
1 parent 786b0dc commit 2cfde24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Versions

## x.x.x
* Fix CTA not clickable in native ads on Android.
## 8.0.0
* Depend on Android SDK 13.0.0 and iOS SDK 13.0.0.
* Removed COPPA support.
Expand Down
19 changes: 14 additions & 5 deletions src/nativeAd/NativeAdViewComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { useContext, useRef, useEffect, useCallback, useMemo } from 'react';
import { findNodeHandle, Text, Image, View, TouchableOpacity, StyleSheet } from 'react-native';
import { findNodeHandle, Text, Image, View, TouchableOpacity, StyleSheet, Platform } from 'react-native';
import type { ViewProps, ImageProps, TextStyle, StyleProp, TextProps } from 'react-native';
import { NativeAdViewContext } from './NativeAdViewProvider';
import type { NativeAd } from '../types/NativeAd';
Expand Down Expand Up @@ -60,13 +60,22 @@ export const CallToActionView = (props: TextProps) => {
const callToActionRef = useRef<Text | null>(null);
const nativeAd = useNativeAdViewProps('callToAction', callToActionRef, 'callToActionView');

return (
<TouchableOpacity>
// TouchableOpacity disables clicking on certain Android devices.
if (Platform.OS === 'android') {
return (
<Text {...props} ref={callToActionRef}>
{nativeAd.callToAction || null}
</Text>
</TouchableOpacity>
);
);
} else {
return (
<TouchableOpacity>
<Text {...props} ref={callToActionRef}>
{nativeAd.callToAction || null}
</Text>
</TouchableOpacity>
);
}
};

export const IconView = (props: Omit<ImageProps, 'source'>) => {
Expand Down

0 comments on commit 2cfde24

Please sign in to comment.