Firebase dynamic links builder API for NodeJS - node.js

I am trying to use firebase cloud functions to build my dynamic link rather than use an android client API
#VisibleForTesting
static Uri buildDeepLink(#NonNull final Uri deepLink, int minVersion) {
String uriPrefix = "https://url.page.link";
DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance()
.createDynamicLink()
.setDomainUriPrefix(uriPrefix)
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder()
.setMinimumVersion(minVersion)
.build())
.setLink(deepLink);
final DynamicLink link = builder.buildDynamicLink();
// Return the dynamic link as a URI
return link.getUri();
}
The above code is for android client, is there a similar code for cloud functions environment?

Firebase Dynamic Links currently has SDKs for creating links for iOS, Android, Unity, and C++. It also has a REST API for other platforms. Since you're not using Android or iOS, you'll have to use the REST API.

If you're feeling lazy, you can also use this small package instead of the REST API:
https://www.npmjs.com/package/firebase-dynamic-links

Related

OpenAPI Generator issue with Destination service API specification

I want to get all destinations on subaccount and instance level. In SAP API business Hub, I found the API information and "SAP Cloud SDK" tab to generate code by OpenAPI generator.
https://api.sap.com/api/SAP_CP_CF_Connectivity_Destination/overview
I downloaded the API specification and added dependencies into Cloud SDK for Java project. The code is generated successfully with some errors (unknown models)in generated api classes.
For example in DestinationsOnSubaccountLevelApi.class, model OneOfDestinationNameOnly is imported and used in method but it is not generated in model package.
I looked into API specification and found that there were two types of response entity. That is the reason why the code could not be generated properly. I can modify the API specification to make it work but it should not be the long term solution. Is there any other way to fix this issue?
Unfortunately the SAP Cloud SDK Generator for Open API services is not yet able to understand oneOf relationship that is modeled in the specification.
As an alternative, would you consider using the DestinationAccessor API for resolving single destinations?
You can also directly instantiate an ScpCfDestinationLoader, which allows for querying all destinations:
ScpCfDestinationLoader loader = new ScpCfDestinationLoader();
DestinationOptions options = DestinationOptions
.builder()
.augmentBuilder(ScpCfDestinationOptionsAugmenter.augmenter().retrievalStrategy(ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER))
.build();
Try<Iterable<ScpCfDestination>> destinations = loader.tryGetAllDestinations(options);
Similar to the default behavior of DestinationAccessor API, in the code above only the subscriber account will be considered. Other options are:
ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER
ScpCfDestinationRetrievalStrategy.ALWAYS_PROVIDER
ScpCfDestinationRetrievalStrategy.SUBSCRIBER_THEN_PROVIDER

How to use existing scanning software dll file using Node js for create Scanning functionality in Node js and Angular 8?

I have a requirement to create scanning functionality using Node js API with existing scanning software in PC. so How can I achieve that type of functionality using Node js and Angular-8.
I have already checked Dynam Twain SDK but it is available only for 30 day trail.
Thanks to all for your help.
Your question is a little confusing. Indeed, Dynamic Web Twain can simply run a web server with node.js to load web applications. But since you already mentioned Angular-8, you may want to use Node.js API to call Dynamic Web Twain to scan pages, right?
Here is a sample shows how to integrate Dynamic Web TWAIN JavaScript library into an Angular project.
export class AppComponent implements OnInit {
title = 'angular-cli-application';
DWObject: WebTwain;
selectSources: HTMLSelectElement;
ngOnInit() {
Dynamsoft.WebTwainEnv.AutoLoad = false;
Dynamsoft.WebTwainEnv.Containers = [{ ContainerId: 'dwtcontrolContainer', Width: '583px', Height: '513px' }];
Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', () => { this.Dynamsoft_OnReady(); });
Dynamsoft.WebTwainEnv.Trial = true;
Dynamsoft.WebTwainEnv.ProductKey = "A-Valid-Product-Key";
//Dynamsoft.WebTwainEnv.ResourcesPath = "https://tst.dynamsoft.com/libs/dwt/15.2";
Dynamsoft.WebTwainEnv.Load();
}
You can find the code here.
And if you want to scan documents with Node.js API on the server-side, you can refer to the code here.

How to build serverless web site on Azure (rather then on AWS Amazon)

How to build serverless web site on Azure, as "auto-scaling, pay-per-execution, event-driven app"?
There are tons of good examples how to build serverless-arhitecture web site on AWS Amazon, e.g. https://zanon.io/posts/building-serverless-websites-on-aws-tutorial
It consumes S3 for HTML and JS, Lambda for REST API, Simple DB for data.
Microsoft has Azure Functions that is analogue for AWS Lambda, but it is "serverless computing", not "serverless web site". I can create "serverless REST API" with Azure Functions, but what about HTML, JS, CSS for web site, database, etc. ?
I tried Azure App Service, but it lacks "pay only for what you use" option, as all plans have Monthly payments, as well as Azure SQL for database. And App Service doesn't seem to be constructed to host serverless-architecture web sites, more for classic ASP.NET web sites that you can easily deploy there.
Also, there is popular library https://github.com/serverless/serverless and they even mentioned Azure: "using AWS Lambda, Azure Functions, Google CloudFunctions & more", but there is no a single example how to use it for Azure and all Docs are for Amazon AWS.
Thanks!
This is an interesting question, and the answer is that you can certainly build a website using Azure functions. You can create a http trigger that returns a static html file that you include in your function. If you want, you can add Javascript or jQuery logic to that file. For even more functionality, you can create more functions that will serve as an API, which you can query from your html file. The API could e.g. utilize Azure storage, where you can cheaply store data in tables or blobs.
Using this pattern, you could in theory build complex web apps on a serverless architecture. I would guess, however, that you would probably find it a bit cumbersome to work with, as the tooling is not really great yet. On the other hand, you would never need to think about hosting/scaling, so that is a big plus.
Just to prove my theory, I implemented a small function app with two c# http trigger functions: One that serves an html file, another one for the api that returns a number. It is just thrown together quickly to prove the point, so I apologize if the code is messy.
HttpTriggerCSharp1:
using System.Net;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.IO;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
var response = new HttpResponseMessage(HttpStatusCode.OK);
var stream = new FileStream(#"d:\home\site\wwwroot\HttpTriggerCSharp1\index.html", FileMode.Open);
response.Content = new StreamContent(stream);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return response;
}
HttpTriggerCSharp2:
using System.Net;
public static async Task<int> Run(HttpRequestMessage req, TraceWriter log)
{
return 42;
}
index.html:
(Note that you will have to add the index.html file to your function files collection)
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
var original = $("#testDiv").text();
$("#testDiv").text(original + " - jQuery added this!");
$("#testButton").click(ButtonClick);
});
var i = 0;
function ButtonClick() {
i++;
var result = i + i;
$.ajax("https://testfunctionwebsite.azurewebsites.net/api/HttpTriggerCSharp2").done(function(a,b) {
var queryResult = a;
$("#ajaxResult").text("Result from api:" + queryResult);
});
$("#ajaxResult").text(result);
}
</script>
<div id="testDiv">
Hello functional world!
</div>
<div>
<button id="testButton">Get some values</button><br>
<div id="ajaxResult"></div>
</div>
</body>
</html>
You can try it out at: https://testfunctionwebsite.azurewebsites.net/api/HttpTriggerCSharp1
For storing static files, you can use Azure Storage, that is comparable to AWS S3:
https://blogs.msdn.microsoft.com/make_it_better/2016/08/09/simple-websites-using-azure-storage-blob-service/
For storing data - there are many options, but if you are looking for NoSQL style DB (implied by you reference of AWS SimpleDB) then you can use Azure DocumentDB:
https://learn.microsoft.com/en-us/azure/documentdb/documentdb-introduction
Both components are "server-less" and pay as you go style billing.
Azure storage accounts now support hosting static websites (currently in preview) to provide serverless websites. This works for static websites like Angular and React SPA applications but does not provide any server side compute like ASP.NET MVC. It can be used with Azure Functions Proxies for additional features. I wrote a post highlight the some features and how to set one up. http://www.deliveron.com/blog/serverless-websites-azure-new-storage-account-static-websites/

How to create Index with custom analyzers from json file in Azure Search .NET SDK?

I had read that the Azure Search .NET SDK uses NewtonSoft.Json to convert it's models to/from json in it's underlying REST API calls so I've been doing the same in my own app.
I have a simple app which creates a new Index using the .NET SDK. To do this, I was defining my Index in a json file, using the format outlined here https://learn.microsoft.com/en-us/rest/api/searchservice/create-index and then I was converting this to a Microsoft.Azure.Search.Models.Index object using Newtonsoft.
var index = JsonConvert.DeserializeObject<Microsoft.Azure.Search.Models.Index>(System.IO.File.ReadAllText("config.json");
This was working fine before I configured custom Analyzers, but now that I have custom Analyzers in my config, the Analyzers, Tokenizers, and TokenFilters are not being resolved into the correct types. ie. my custom Analyzer is being deserialized as a Microsoft.Azure.Search.Models.Analyzer, instead of Microsoft.Azure.Search.Models.CustomAnalyzer, same goes for the Tokenizers and TokenFilters, they are being deserialized into the base types.
Is there an easy way I can create an Index like this in the .NET SDK from a json file?
Unfortunately this is not an officially supported scenario. While it works for simple index definitions, we're working to understand what we need to do to be able to support all cases.
Please post your feature request on our User Voice page to help us prioritize: https://feedback.azure.com/forums/263029-azure-search
In the meantime, you might be able to get it working yourself by adapting the JsonSerializerSettings initialization code at the bottom of this file.

Unable to open Google Play store with Xamarin.Forms Portable class Library

Currently I use this to try and open the Google Play Store directly to my app however this does not work.
var intent = new Intent(Intent.ActionView, Uri.Parse("market://details?id=" + appPackageName));
In a Forms PCL project, you can open a URI by using Device.OpenUri()
Device.OpenUri(new Uri("http://www.google.com"));

Resources