I am trying to integrate Android Deeplink with a HTTP server in node.js. Actually, if I create an end point with express server, like
app.get('/deeplink', deeplink({
fallback: 'https://na.nor.com',
android_package_name: 'com.na.nor'
}));
it will work fine. But actually I need to integrate with a normal http server.
Yes I have done my job to work it with HTTP end point.No need to require deep-link instead of just modified deep-link library to use with HTTP middle ware. Posting following code ,hope it will help to someone.Thanks
var file = fs.createReadStream(path.join(__dirname, '/public/index.html'));
var options={
fallback: config.deeplink_fallback,
android_package_name:config.deeplink_package_name
};
var detoken = new stream.Transform({ objectMode: true });
detoken._transform = function (chunk, encoding, done) {
var data = chunk.toString()
Object.keys(options).forEach(function (key) {
data = data.replace('{{' + key + '}}', options[key])
});
this.push(data);
done();
}
var inline = inliner({ basedir: path.join(__dirname, '/public') });
res.statusCode=200;
res.setHeader('Content-Type', 'text/html; charset=utf-8');
var newdt=file.pipe(detoken).pipe(inline);
newdt.pipe(res);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.