Make all referrer info sync (#4782)
parent
f021c06468
commit
306f162639
|
@ -23,7 +23,7 @@ class ExpoBlueskyReferrerModule : Module() {
|
||||||
activityReferrer = appContext.currentActivity?.referrer
|
activityReferrer = appContext.currentActivity?.referrer
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("getReferrerInfoAsync") {
|
Function("getReferrerInfo") {
|
||||||
val intentReferrer =
|
val intentReferrer =
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
intent?.getParcelableExtra(Intent.EXTRA_REFERRER, Uri::class.java)
|
intent?.getParcelableExtra(Intent.EXTRA_REFERRER, Uri::class.java)
|
||||||
|
@ -40,7 +40,7 @@ class ExpoBlueskyReferrerModule : Module() {
|
||||||
"hostname" to intentReferrer.host,
|
"hostname" to intentReferrer.host,
|
||||||
)
|
)
|
||||||
intent = null
|
intent = null
|
||||||
return@AsyncFunction res
|
return@Function res
|
||||||
}
|
}
|
||||||
|
|
||||||
// In all other cases, we'll just record the app that sent the intent.
|
// In all other cases, we'll just record the app that sent the intent.
|
||||||
|
@ -52,10 +52,10 @@ class ExpoBlueskyReferrerModule : Module() {
|
||||||
"hostname" to (activityReferrer?.host ?: ""),
|
"hostname" to (activityReferrer?.host ?: ""),
|
||||||
)
|
)
|
||||||
activityReferrer = null
|
activityReferrer = null
|
||||||
return@AsyncFunction res
|
return@Function res
|
||||||
}
|
}
|
||||||
|
|
||||||
return@AsyncFunction null
|
return@Function null
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncFunction("getGooglePlayReferrerInfoAsync") { promise: Promise ->
|
AsyncFunction("getGooglePlayReferrerInfoAsync") { promise: Promise ->
|
||||||
|
|
|
@ -8,6 +8,6 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
|
||||||
return NativeModule.getGooglePlayReferrerInfoAsync()
|
return NativeModule.getGooglePlayReferrerInfoAsync()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
export function getReferrerInfo(): Promise<ReferrerInfo | null> {
|
||||||
return NativeModule.getReferrerInfoAsync()
|
return NativeModule.getReferrerInfo()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
|
||||||
throw new NotImplementedError()
|
throw new NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
export function getReferrerInfo(): ReferrerInfo | null {
|
||||||
const referrer = SharedPrefs.getString('referrer')
|
const referrer = SharedPrefs.getString('referrer')
|
||||||
if (referrer) {
|
if (referrer) {
|
||||||
SharedPrefs.removeValue('referrer')
|
SharedPrefs.removeValue('referrer')
|
||||||
|
@ -19,7 +19,7 @@ export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
referrer,
|
referrer,
|
||||||
hostname: undefined,
|
hostname: referrer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
|
||||||
throw new NotImplementedError()
|
throw new NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
export function getReferrerInfo(): ReferrerInfo | null {
|
||||||
throw new NotImplementedError()
|
throw new NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
|
||||||
throw new NotImplementedError()
|
throw new NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
|
export function getReferrerInfo(): ReferrerInfo | null {
|
||||||
if (
|
if (
|
||||||
Platform.OS === 'web' &&
|
Platform.OS === 'web' &&
|
||||||
// for ssr
|
// for ssr
|
||||||
|
|
|
@ -771,15 +771,14 @@ function logModuleInitTime() {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
Referrer.getReferrerInfoAsync().then(info => {
|
const referrerInfo = Referrer.getReferrerInfo()
|
||||||
if (info && info.hostname !== 'bsky.app') {
|
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
|
||||||
logEvent('deepLink:referrerReceived', {
|
logEvent('deepLink:referrerReceived', {
|
||||||
to: window.location.href,
|
to: window.location.href,
|
||||||
referrer: info?.referrer,
|
referrer: referrerInfo?.referrer,
|
||||||
hostname: info?.hostname,
|
hostname: referrerInfo?.hostname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
|
|
|
@ -18,15 +18,14 @@ export function useIntentHandler() {
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const handleIncomingURL = (url: string) => {
|
const handleIncomingURL = (url: string) => {
|
||||||
Referrer.getReferrerInfoAsync().then(info => {
|
const referrerInfo = Referrer.getReferrerInfo()
|
||||||
if (info && info.hostname !== 'bsky.app') {
|
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
|
||||||
logEvent('deepLink:referrerReceived', {
|
logEvent('deepLink:referrerReceived', {
|
||||||
to: url,
|
to: url,
|
||||||
referrer: info?.referrer,
|
referrer: referrerInfo?.referrer,
|
||||||
hostname: info?.hostname,
|
hostname: referrerInfo?.hostname,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
// We want to be able to support bluesky:// deeplinks. It's unnatural for someone to use a deeplink with three
|
// We want to be able to support bluesky:// deeplinks. It's unnatural for someone to use a deeplink with three
|
||||||
// slashes, like bluesky:///intent/follow. However, supporting just two slashes causes us to have to take care
|
// slashes, like bluesky:///intent/follow. However, supporting just two slashes causes us to have to take care
|
||||||
|
|
Loading…
Reference in New Issue