Manually constructing a Dynamic Link URL with OFL Parameter not working on Desktop Browser - firebase

I created dynamic link (React-Native App) which is working perfectly on Android & iOS devices but if open same link on desktop browser it say "Dynamic link not found/Invalid dynamic link". I have created custom dynamic link as well as using Firebase dynamic link
--- Using Firebase Link ---
await firebase.dynamicLinks().buildShortLink(
{
domainUriPrefix: `${prefix_url}`,
link: `${prefix_url}/${params}`,
android: {
packageName: `${package_name}`,
},
ios: {
bundleId: `${bundle_id}`,
appStoreId: 'xxxxxxxxxx',
},
otherPlatform: {
fallbackUrl: `${web_url}`,
},
},
firebase.dynamicLinks.ShortLinkType.UNGUESSABLE,
);
--- By Custom Link ---
longDynamicLink: `${prefix_url}/?link=${link_url}&apn=${package_name}&ibi=${bundle_id}&isi=xxxxxxxxx&ofl=${web_url}`,
suffix: {
option: 'UNGUESSABLE',
},
};
Issue -: Link on desktop browser not working (fallback url not working)
Dynamic link should redirect a website link on desktop

Related

Firebase dynamic link acting differently if generated on iOS (React Native) vs REST API

We have a functionality to generate dynamic links to our app on iOS using React Native, which works perfectly (identifiable data redacted by replacing them with "our app"):
dynamicLinks().buildShortLink({
link: `https://our_app?referral=${referralCode}`,
domainUriPrefix: 'https://ourapp.page.link',
android: {
packageName: 'app.ourapp.mobile',
},
ios: {
appStoreId: 'XXX',
bundleId: 'app.ourapp.client',
},
navigation: {
forcedRedirectEnabled: true,
},
});
It correctly opens the app if installed, and App Store if not installed.
I need to implement the same functionality on web site, here's my code:
const payload = {
dynamicLinkInfo: {
link: `https://our_app.app?referral=${referralCode}`,
domainUriPrefix: 'https://ourapp.page.link',
androidInfo: {
androidPackageName: 'app.ourapp.mobile',
},
iosInfo: {
iosBundleId: 'XXX',
iosBundleId: 'app.ourapp.client',
},
navigationInfo: {
enableForcedRedirect: true,
},
}
};
// generate page link and redirect there
const result = await fetch('https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=OUR_API_KEY', {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
It's the same (with parameter names from React Native changed to REST parameter names respectively, as documented at https://firebase.google.com/docs/reference/dynamic-links/link-shortener)
A link is generated, however when clicked, if the app isn't installed, the page link redirects our website instead of App Store.
When I debug both links using ?d=1 query string parameter, I can indeed notice the difference:
(left: in-app generated, correct. right: REST-generated, incorrect)
Why are these links, generated with the exact same parameters, behaving differently and how can I make the second one work exactly like the first one (redirect to App Store instead of our website)?
After examining closely I've found a typo:
While generating the link in the second example, I was mistakenly using the same key twice:
iosInfo: {
iosBundleId: 'XXX',
iosBundleId: 'app.ourapp.client',
},
Changed the first one to iosAppStoreId and it worked.

Access images in public folder from pages/api in nextJS using nodemailer [duplicate]

This question already has an answer here:
Next.js: How to get static assets from within getStaticProps
(1 answer)
Closed 3 months ago.
using these versions
"next": "12.0.7"
"nodemailer": "^6.7.2"
I am building a mailing service using NextJS, but i encountered some problems:
gmail not rendering the images (solved by sending as attachment the images i want to render)
In production, the mailing service can't find the images inside the public folder
Mails sent in dev environment work perfect, but in production the images don't render
I have the following structure
pages
-api
-contact.js
public
-images
-image_name.png
in contact.js
as suggested here
...
mailData = {
from: process.env.THE_EMAIL,
to: req.body.email,
subject: `SOME_SUBJECT`,
attachments: [
{
filename: 'image_name.png',
path: 'public/images/image_name.png',
cid: 'SOME_ID_FOR_NODEMAILER',
}
]}
...
When Im working in localhost, the mailing service works perfect and the images are found, but when is in production (deployed with Vercel) it cannot find the images.
Any thoughts or alternatives?
Should i host the images in a CDN and forget about it?
this worked for me, following this article
const mailOptions = {
from: 'fromEmailAddress#gmail.com',
to: email,
replyTo: email,
subject: `${emailSubject}`,
html: emailBody,
attachments: [
{
filename: `invoice-${invoiceNumber}.pdf`,
path: process.cwd() + '/public/invoice.pdf'
}
]
}

Deep Link doesn't open the app instead does a google search

I have been using Expo to develop a react-native app, The functionality I am currently trying to implement is to share a link with friends on platforms such as fb messenger/whatapp or even normal texts and when they click this link it will launch my app to a specific page using the parameters.
After extensive research online - I’ve come to a blocker, following expo’s documentation I defined a scheme for my app - when I press share everything works correctly a message is created and I’m able to share content but only as string.
I am using react-natives Share library to share to an app and I’m using Expo to provide me with the link.
Ideally my first goal is to get the app opening using the Expo Link before I explore further into adding more functionality to the link.
Share.share({
message: "Click Here to View More! " + Linking.makeUrl( ' ' , { postkey : "7a5d6w2x9d6s3a28d8d});
url: Linking.makeUrl( ' ' , { pkey : gkey });
title: 'This post is amazing',
})
.then((result) =>{
console.log(result)
if(result === 'dismissedAction'){
return
}
})
.catch((error) => console.log(error))
In the root of my app I have also defined the event handlers: App.js
_handleRedirect=(event)=> {
let {path,queryParams} = Linking.parse(event);
Alert.alert(`queryparams : ${event} path : ${path} `)
this.props.navigation.navigate("Post_Detail",{key:queryParams.postkey})
}
}
componentDidMount() {
let scheme = 'nxet'
Linking.getInitialURL()
.then(url => {
console.log("App.js getInitialURL Triggered")
// this.handleOpenURL({ url });
})
.catch(error => console.error(error));
Linking.addEventListener('url', ({url}) => this._handleRedirect(url));;
}
componentWillUnmount() {
Linking.removeEventListener('url', this.handleOpenURL);
}
When I share the link to Whatsapp, Facebook Messenger or even just messages or notes it appears as myapplink://, I try to enter this into the browser and instead of asking me to open my app - it does a google search.
Please note I am attempting to have this working on Android Device and facing this issue
Is there something I am doing incorrectly?
Any help is much appreciated. Thanks.
You can not open external links, means other than http, https on Android. But you can on iOS. In order to be able to open your expo links, you need proper anchor tags on android. You can create html mails and give it a try, you will see it is gonna work on Android as well.

Firebase short links fallback link

I'm using Firebase dynamic links with link shortener and I want to define fallback link for clients beside Android and iOS. Manually constructed dynamic links have parameter ofl that does exactly what I need The link to open on platforms beside Android and iOS. However it seems that this parameter is missing in shortener documentation. Although ofl is mention in the description of link parameter in shortener docs When users open a Dynamic Link on a desktop web browser, they will load this URL (unless the ofl parameter is specified).
Is it possible to somehow add a fallback url for clients beside Android and iOS (e.g. web) to redirect users there instead of link parameter
By using REST API
POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=api_key
Content-Type: application/json
{
"dynamicLinkInfo": {
"domainUriPrefix": "https://example.page.link",
"link": "https://www.example.com/",
"androidInfo": {
"androidPackageName": "com.example.android"
},
"iosInfo": {
"iosBundleId": "com.example.ios"
},
"desktopInfo": {
"desktopFallbackLink": "https://www.other-example.com/"
},
}
}
The simplest way to set fallback url in short dynamic link is to create long link manually and then use sdk to convert it to short one:
val longLink = "$domain/?link=$deepLink&apn=$androidPackage&ibi=$iosPackage&isi=$iosAppStoreId&ofl=$desktopFallbackLink"
FirebaseDynamicLinks
.getInstance()
.createDynamicLink()
.setLongLink(Uri.parse(link))
.buildShortDynamicLink()
.addOnSuccessListener {
val shortLink = it.shortLink
//do something with the link here
}

react native share dynamic link

1.Everything work fine before share, I shared to Facebook Messenger and click the social content, the redirect link is not the link that firebase generated. The link has become the dynamic domain mixed with the title and description.
2.I tried to copy only the generated firebase link and paste to Facebook Messenger, social content loaded, then by clicking the content it call the dynamic link correctly and launch the app.
const link = new firebase.links.DynamicLink('https://example.com/parameter' , 'abc123.app.goo.gl')
.android.setPackageName('com.example.android')
.ios.setBundleId('com.example.android')
.social.setTitle("Social Title")
.social.setImageUrl("http://exmaple.com/super.png")
.social.setDescriptionText("Description");
firebase.links().createShortDynamicLink(link, 'SHORT')
.then((url) => {
Share.share({
message: "Message Title",
url: url,
title: "Title"
}, {
// Android only:
dialogTitle: 'Super Share'
})
// ...
});
How to share with correct dynamic link not just copy and paste, consider the user behavior.

Resources