I am using the dynamic links plugin to create a link, I want that when user clicks on the link if her or she is not on android then he or she must be sent to a website as I have only an android app, but if on android then he must be sent to the app. How to get the desired result? there is no method in the plugin for fallback links for different os. I am creating a dynamic link through code and not in the firebase console.
according to firebase while constructing dynamic links manually we can give Other platform parameters as ofl:
ofl: The link to open on platforms besides Android and iOS. This is useful to specify a different behavior on a desktop, like displaying a full web page of the app content/payload (as specified by param link) with another dynamic link to install the app.
it also has a ifl, i.e if app is not installed on ios:
ifl: The link to open when the app isn't installed. Specify this to do something other than install your app from the App Store when the app isn't installed, such as open the mobile web version of the content, or display a promotional page for your app.
But can't find both ifl and ofl feature in the flutter firebase dynamic links plugin.
You can manually add ofl (or afl, or ifl) to the long Uri string and use it directly, or even build a short URL from it.
This code creates a DynamicLinkParameters variable parameters using the DynamicLinkParameters() constructor inside an async function, then uses it to create a short link that falls back to https://example.com on desktop:
final DynamicLinkParameters parameters = DynamicLinkParameters(
// constructor arguments
);
final Uri longLink = await parameters.buildUrl();
final ShortDynamicLink shortDynamicLink = await DynamicLinkParameters.shortenUrl(Uri.parse(longLink.toString() + "&ofl=https://example.com"));
final Uri dynamicLinkShortUrl = shortDynamicLink.shortUrl;
If i understood your problem correctly, you want to use a link if the user is on android and other if the user is on ios. That can be done importing dart:io and doing something like this:
if (Platform.isAndroid) {
// add the link to the android page
} else if (Platform.isIOS) {
// do something else
}
Related
I have site that deployed on firebase hosting site
on the site I wrote Version 3 but instead of that I want to show the deployment / release version like e925c5 that writen on the history version.
can I get history version with Rest API.? or can I define it before deployed.?
thank you
Update
I try with reading documentation and working with it, but still stuck with the authentication method,
Simple function is this, but always returned 403 response, already try with getGlobalDefaultAccount.login() and getGlobalDefaultAccount.getAccessToken() and getGlobalDefaultAccount() still not working,
const requireAuth = require('firebase-tools/lib/requireAuth')
const getGlobalDefaultAccount = require('firebase-tools/lib/auth')
const api = require('firebase-tools/lib/api')
const site = 'sarafe-testing'
requireAuth(getGlobalDefaultAccount.getAccessToken(), ['https://www.googleapis.com/auth/cloud-platform']).then(async () => {
try {
const response = await api.request('GET', `/v1beta1/sites/${site}/releases`, { auth: true, origin: api.hostingApiOrigin })
console.log(response)
} catch(e) {
console.log(e.message)
}
})
Full version
For now I just created table that hold version code (manuali update from firebase page) and make API to get the version, but this not a valid solution because is only show the latest version, some other people just open the webpage without refresh / clear cache so that one is still using the old version of webpage with latest version written,
Yes, there is a REST API that allows you to manage versions and releases for Firebase Hosting, and it has a method to get a list of versions for the site. I recommend checking out its documentation and reporting back if you get stuck while implementing the code.
In a previous Stack Overflow question, I shied away from using an external webhook on Actions on Google
so I needed to go back to the inline editor. I got that worked out, but now I'm feeling brave again.
I've outgrown the inline editor and want the ability to develop my code on my laptop, testing it in Firebase, and publishing to a site for my webhook, presumably where the inline code editor publishes to. In fact, I have already written the require functions and deployed them from Firebase. So the full functionality is ready to go, I just need to hook it up properly to Actions on Google.
What I have now in Actions on Google, inline editor, is more of a stub. I want to merge that stub into my more fullblown logic that I have in Firebase. Here is what is in the inline editor:
const { conversation } = require('#assistant/conversation');
const functions = require('firebase-functions');
const app = conversation();
app.handle('intent_a_handler', conv => {
// Implement your code here
conv.add("Here I am in intent A");
});
app.handle('intent_b_handler', conv => {
// Implement your code here
conv.add("Here I am in intent B");
});
exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);
When I search on the Internet, I see discussion from the point of view of Dialogflow, but like I say, I'm in "Actions on Google". I want to transition away from the inline editor, taking what I already have, as a basis.Can someone explain how I set that up? I'm happy to do this within the context of the Google ecosystem.
To test your own webhook locally on your own system I would recommend incorporating a web app framework such as express. With express you can host code on your local machine and make it respond to request from Actions on Google. In your case you would replace this will all the code related to the Firebase functions package. Here is an example of what a simple webhook for Actions on Google looks like:
const express = require('express');
const bodyParser = require('body-parser')
const { conversation } = require('#assistant/conversation');
const exprs = express();
exprs.use(bodyParser.json()) // allows Express to work with JSON requests
const app = conversation();
app.handle('example intent', () => {
// Do something
})
// More app.handle() setups
exprs.post('/', app);
exprs.listen(3000);
With this setup you should be able to run your own application locally. The only thing you need to do is install the required dependencies and add your own intent handlers for your action. At this point you have a webhook running on your own machine, but that isn't enough to use it as a webhook in Actions on Google because it runs locally and isn't publicly available via the internet.
For this reason we will be using a tool called ngrok. With ngrok you can create a public https address that runs all messages to your local machine. This way you can use ngrok address as your webhook URL. Now you can just make as many code changes as you want and Actions on Google will automatically use the latest changes when you develop. No need to upload and wait for Firebase to do this.
Just to be clear: Ngrok should only be used for development. When you are done with developing your action you should upload all your code to a cloud service or host it on your own server if you have any. A (free plan) ngrok URL usually expires every 6 hours. So its not a suitable solution for anything other than development.
firebase dynamic links
I have successfully created an url prefix (giftittest.page.link) to which I have added a dynamic link (giftittest.page.link/list).
I followed the procedure to add an associated domain to xcode.
xcode associated domains
From safari I insert in the url 'giftittest.page.ling/list', it offers me to open my app, I press ok, the app opens correctly and I can intercept the dynamic link with the function
dynamicLinks().onLink(dynamicLinks => {
console.log({dynamicLinks})
})
and
dynamicLinks().getInitialLink(getInitialLink => {
console.log({getInitialLink})
})
how can I pass parameters to my app in query string?
I am trying to handle dynamic links within my flutter app and they work perfectly when the app is already installed. The link works fine regardless if the app is open or closed in the background. However when I try to use a link when the app is not installed I am properly brought to the app store, but then once I open the app from within the app store after the install completes it just opens the app and my dynamic link functionality never executes.
My dynamic link is similar to this:
https://startingxi.page.link/?link=https://url-redacted/game/gameId&apn=myapn&isi=mysi&ibi=myibi&st=new%20team%20vs%20&sd=1%20-%202&efr=1
I have tried with both efr=1 and without that.
My flutter code:
#override
void initState() {
super.initState();
initDynamicLinks();
futureInitState = initStateAsync();
}
Future<void> initDynamicLinks() async {
final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
final Uri deepLink = data?.link;
await processDeepLink(deepLink);
FirebaseDynamicLinks.instance.onLink(onSuccess: (PendingDynamicLinkData dynamicLink) async {
final Uri deepLink = dynamicLink?.link;
await processDeepLink(deepLink);
}, onError: (OnLinkErrorException e) async {
print('onLinkError');
print(e.message);
displayFlushBar('$e.message');
});
}
I have tried putting the initDynamicLinks within my futureInitState which is part of my FutureBuilder which does other async stuff at startup. Any help would be appreciated. I'm not sure how to debug this problem and this is my first ios/app dev experience so I'm not sure if there are some logs on the ios device that may help? But at the moment it seems as though I need to deploy to production and get my change live in the app store before I can test anything and that seems less than ideal. But since the dynamic link works in the other use cases I'm stumped on troubleshooting.
Thanks!
Common troubleshooting steps for issues on opening Firebase Dynamic Links after app install is to make sure that value of the ibi parameter matches the app's Bundle ID.
For Google-provided *.page.link domains: in the Capabilities tab of the app's Xcode project, Associated Domains shoudld be enabled, and the following is added in the Associated Domains list: applinks:{your_dynamic_links_domain}.
Also, verify that the AASA of your FDL https://{your_dynamic_links_domain}/apple-app-site-association contains an entry for your app. Verify "appID":"{team-id}.{bundle-id}" values are correct for your app
If these steps didn't work, it's best to reach out to Firebase Support as they have the tools to diagnose deeper into this issue.
I am trying to get the current URL in an AppMaker app. However, the standard JavaScript ways do not work, ScriptApp is not available in AppMaker, and the objects that are in AppMaker do not return the correct URL (that starts with https://script.google.com).
Thanks for any suggestions.
You can run a backend/serverside script and use Apps Script
ScriptApp.getService().getUrl()
See the doc ScriptApp Documentation
To have an app URL on client side, you can load it during app startup. Firstly, let's create server script that returns app URL:
/**
* Get the URL of the published web app.
*/
function getAppUrl() {
return ScriptApp.getService().getUrl();
}
Open your Project settings and put next code to App startup script section:
loader.suspendLoad();
google.script.run.withSuccessHandler(function(url) {
appUrl = url;
loader.resumeLoad();
}).getAppUrl();
Now you are able to use appUrl everywhere in Client Scripts.
Using this approach you can create initial app config on startup that requires specific data from server.