Adaptive card is not rendered on Teams mobile app - android

We have an external bot configured to use MS Teams channel using message end point web hook. The following is the message posted to the Ms Teams channel by the external bot. This response gets rendered as expected when MS Teams is accessed via web browser or MS Teams application on desktop computer. However, the card is not rendered (seeing an empty line/block without any content) when used with Teams application on an android mobile phone. Would like to know what is going wrong here?Is this feature not supported on mobile? or are we missing something?
"channelData":{
"tenant":{
"id":"xxxxxxxxxxxxxx"
}
},
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"content":{
"fallbackText":"Adaptive card version not supported",
"type":"AdaptiveCards",
"body":[
{
"text":"Here is an adaptive card with a link to a task module",
"type":"TextBlock"
},
{
"type":"Image",
"url":"http://adaptivecards.io/content/cats/1.png"
}
],
"version":"1.0",
"actions":[
{
"type":"Action.OpenUrl",
"title":"Open Link",
"url":"https://teams.microsoft.com/l/task/xxxxx?url=https%3A%2F%2Fwww.wikipedia.com%0A&height=large&width=large&title=Wikipedia-Embed"
}
]
}
}
],
"replyToId":"xxxxxx",
"serviceUrl":"https://smba.trafficmanager.net/amer/",
"recipient":{
"name":"xxxx xxxx",
"aadObjectId":"xxxxx",
"id":"xx:xxxxxxxx"
},
"localTimestamp":"2020-02-14T15:21:41.1360000-08:00",
"channelType":"msteams",
"from":{
"name":"xxxxxx",
"id":"xx:xxxxx"
},
"type":"message",
"conversation":{
"conversationType":"personal",
"tenantId":"xxxxxx",
"id":"x:xxxxxx"
}
}```

You need to make sure the card's "type" is "AdaptiveCard" and not "AdaptiveCards".
{
"fallbackText":"Adaptive card version not supported",
"type":"AdaptiveCard",
"body":[
{
"text":"Here is an adaptive card with a link to a task module",
"type":"TextBlock"
},
{
"type":"Image",
"url":"http://adaptivecards.io/content/cats/1.png"
}
],
"version":"1.0",
"actions":[
{
"type":"Action.OpenUrl",
"title":"Open Link",
"url":"https://teams.microsoft.com/l/task/xxxxx?url=https%3A%2F%2Fwww.wikipedia.com%0A&height=large&width=large&title=Wikipedia-Embed"
}
]
}

Related

Flutter: How to detect that the app is running on LD Player

I am working in a Flutter app with some security requirements, one of them is to prevent the app from working in Emulators, just real devices, in order to prevent the screenshots and screen recordings from the Emulators.
I have used safe_device and device_info_plus packages to detect whether the app is running on Emulator or Physical device and every thing is working fine but when I tried LD Player Emulator the packages failed to detect that it is emulator because it is very good at mocking the real device.
So any ideas to detect that the device is running on LD Player?
Here is the output from device_info_plus which might be helpful:
{
"id": "N2G48B",
"host": "ubuntu",
"tags": "release-keys",
"type": "user",
"model": "ASUS_Z01QD",
"board": "SM-G975N",
"brand": "asus",
"device": "aosp",
"product": "SM-G975N",
"display": "N2G48B",
"hardware": "android_x86",
"androidId": null,
"bootloader": "unknown",
"version": {
"baseOS": "",
"sdkInt": 25,
"release": "7.1.2",
"codename": "REL",
"incremental": "V9.5.8.0.OCACNFA",
"previewSdkInt": 0,
"securityPatch": "2017-10-05"
},
"fingerprint": "google/android_x86/x86:7.1.2/N2G48B/V9.5.8.0.OCACNFA:user/release-keys",
"manufacturer": "asus",
"supportedAbis": [
"x86",
"armeabi-v7a",
"armeabi"
],
"systemFeatures": [
"android.hardware.sensor.proximity",
"android.hardware.sensor.accelerometer",
"android.software.controls",
"android.hardware.faketouch",
"android.hardware.usb.accessory",
"android.software.backup",
"android.hardware.touchscreen",
"android.hardware.touchscreen.multitouch",
"android.software.print",
"android.hardware.ethernet",
"android.software.activities_on_secondary_displays",
"android.hardware.wifi.rtt",
"com.google.android.feature.PIXEL_2017_EXPERIENCE",
"android.software.voice_recognizers",
"com.google.lens.feature.CAMERA_INTEGRATION",
"android.software.picture_in_picture",
"android.hardware.fingerprint",
"android.hardware.sensor.gyroscope",
"android.hardware.audio.low_latency",
"android.software.vulkan.deqp.level",
"com.google.android.feature.PIXEL_2018_EXPERIENCE",
"android.hardware.opengles.aep",
"android.hardware.bluetooth",
"android.hardware.camera.autofocus",
"com.google.android.feature.GOOGLE_BUILD",
"android.hardware.telephony.gsm",
"android.hardware.telephony.ims",
"android.software.sip.voip",
"android.hardware.vr.high_performance",
"android.hardware.usb.host",
"android.hardware.audio.output",
"android.software.verified_boot",
"android.hardware.camera.flash",
"android.hardware.camera.front",
"android.hardware.sensor.hifi_sensors",
"android.hardware.se.omapi.uicc",
"android.hardware.screen.portrait",
"android.hardware.nfc",
"com.google.android.feature.TURBO_PRELOAD",
"android.hardware.sensor.ambient_temperature",
"com.nxp.mifare",
"android.hardware.sensor.stepdetector",
"android.software.home_screen",
"android.hardware.microphone",
"android.software.autofill",
"android.software.securely_removes_users",
"android.software.vr.mode",
"com.google.android.feature.PIXEL_EXPERIENCE",
"android.hardware.bluetooth_le",
"android.hardware.sensor.compass",
"android.hardware.touchscreen.multitouch.jazzhand",
"android.hardware.sensor.barometer",
"android.software.app_widgets",
"android.software.input_methods",
"android.hardware.sensor.light",
"android.hardware.vulkan.version",
"android.software.companion_device_setup",
"android.software.device_admin",
"com.google.android.feature.WELLBEING",
"android.hardware.wifi.passpoint",
"android.hardware.camera",
"com.google.android.feature.ZERO_TOUCH",
"android.hardware.screen.landscape",
"android.software.device_id_attestation",
"android.hardware.ram.normal",
"android.software.managed_users",
"android.software.webview",
"android.hardware.sensor.stepcounter",
"android.hardware.camera.capability.manual_post_processing",
"com.google.ar.core.depth",
"android.hardware.camera.any",
"android.hardware.camera.capability.raw",
"android.software.connectionservice",
"android.hardware.touchscreen.multitouch.distinct",
"android.hardware.location.network",
"android.software.cts",
"android.software.sip",
"android.hardware.camera.capability.manual_sensor",
"android.software.app_enumeration",
"com.google.android.apps.dialer.SUPPORTED",
"android.hardware.camera.level.full",
"android.hardware.wifi.direct",
"android.software.live_wallpaper",
"com.google.android.feature.GOOGLE_EXPERIENCE",
"android.software.ipsec_tunnels",
"com.google.android.feature.EXCHANGE_6_2",
"android.software.freeform_window_management",
"android.hardware.audio.pro",
"android.hardware.nfc.hcef",
"android.hardware.location.gps",
"android.software.midi",
"android.hardware.nfc.any",
"android.hardware.nfc.hce",
"android.hardware.wifi",
"android.hardware.location",
"android.hardware.vulkan.level",
"android.hardware.wifi.aware",
"android.software.secure_lock_screen",
"android.hardware.telephony",
"android.software.file_based_encryption",
null
],
"isPhysicalDevice": true,
"supported32BitAbis": [
"x86",
"armeabi-v7a",
"armeabi"
],
"supported64BitAbis": []
}
The solution is to check for the existence of these folders, if any of them exists, then it is an LD Player.
'/storage/emulated/0/storage/secure',
'/storage/emulated/0/Android/data/com.android.ld.appstore'
I have implemented a method to take a list of folders paths and return true if any of them exists, which is the following:
bool anyFolderExists(List<String> foldersPaths) {
for (String folderPath in foldersPaths) {
if (Directory(folderPath).existsSync()) {
return true;
}
}
return false;
}
and I'm using it like this:
List<String> harmfulFoldersPaths = [
'/storage/emulated/0/storage/secure',
'/storage/emulated/0/Android/data/com.android.ld.appstore',
];
if(anyFolderExists(harmfulFoldersPaths))
{
print('LD Player Detected!');
}
Also I am using these two values from the output of device_info_plus package to decide that the app is working on an Emulator because they seems very generic:
"host": "ubuntu",
"device": "aosp",
I am using them like the following:
final androidInfo = await deviceInfoPlugin.androidInfo;
if (androidInfo.host == 'ubuntu' && androidInfo.device == 'aosp') {
print('LD Player Detected!');
}
But to be honest, I am afraid of this approach because I do not want to block any user by mistake, so I am using them with Firebase Remote Config to enable/disable it at any time but until now I am enabling them without any problem recorded.
Check this Package
https://pub.dev/packages/safe_device
bool isRealDevice = await SafeDevice.isRealDevice;
this method returns false if running device is an emulator

Android - PWA does not open in standalone mode with service worker

While developing a Progressive-Web-App the following Problem occurred:
Standalone mode works perfectly without including the service worker - but does NOT work with.
Without Service-Worker a2hs (added to Homescreen) PWA gets correctly started in "standalone"-Mode.
After adding the Service-Worker (a2hs + installed / Web-APK) PWA opens new Tab in new Chrome-Window.
Chrome-PWA-Audit:
login_mobile_tablet.jsf / include service worker:
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('../serviceWorker.js', {scope: "/application/"})
/* also tried ".", "/", "./" as scope value */
.then(function(registration) {
console.log('Service worker registration successful, scope is: ', registration.scope);
})
.catch(function(error) {
console.log('Service worker registration failed, error: ', error);
});
}
</script>
serviceWorker.js:
var cacheName = 'pwa-cache';
// A list of local resources we always want to be cached.
var filesToCache = [
'QS1.xhtml',
'pdf.xhtml',
'QS1.jsf',
'pdf.jsf',
'login_pages/login_mobile_tablet.jsf',
'login_pages/login_mobile_tablet.xhtml'
];
// The install handler takes care of precaching the resources we always need.
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(cacheName).then(function(cache) {
return cache.addAll(filesToCache);
})
);
})
// The activate handler takes care of cleaning up old caches.
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
});
// The fetch handler serves responses for same-origin resources from a cache.
self.addEventListener('fetch', event => {
// Workaround for error:
// TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode
// see: https://stackoverflow.com/questions/48463483/what-causes-a-failed-to-execute-fetch-on-serviceworkerglobalscope-only-if
if (event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin')
return;
event.respondWith(
caches.match(event.request, {ignoreSearch: true})
.then(response => {
return response || fetch(event.request);
})
);
});
manifest.json:
{
"name":"[Hidden]",
"short_name":"[Hidden]",
"start_url":"/application/login_pages/login_mobile_tablet.jsf",
"scope":".",
"display":"standalone",
"background_color":"#4688B8",
"theme_color":"#4688B8",
"orientation":"landscape",
"icons":[
{
"src":"javax.faces.resource/images/icons/qsc_128.png.jsf",
"sizes":"128x128",
"type":"image/png"
},
{
"src":"javax.faces.resource/images/icons/qsc_144.png.jsf",
"sizes":"144x144",
"type":"image/png"
},
{
"src":"javax.faces.resource/images/icons/qsc_152.png.jsf",
"sizes":"152x152",
"type":"image/png"
},
{
"src":"javax.faces.resource/images/icons/qsc_192.png.jsf",
"sizes":"192x192",
"type":"image/png"
},
{
"src":"javax.faces.resource/images/icons/qsc_256.png.jsf",
"sizes":"256x256",
"type":"image/png"
},
{
"src":"javax.faces.resource/images/icons/qsc_512.png.jsf",
"sizes":"512x512",
"type":"image/png"
}
]
}
The following questions / answers were considered - but no solution was found:
PWA wont open in standalone mode on android
WebAPK ignores display:standalone flag for PWA running on local network
PWA deployed in node.js running in Standalone mode on Android and iOS
Technical Background
The Moment you add your Service-Worker (along all other PWA-Requirements) your App gets created as an Real PWA - with Web-APK getting installed.
Therefore you also need to use Default-HTTPS-Port 443 - make sure you use a valid HTTPS-Certificate.
Before adding the Service-Worker, this mandatory requirement was missing so your PWA was NOT installed and therefore needed less other requirements to be displayed in "standalone-mode".
It's just a shame that this is nowhere documented... and we had to "find out" for ourselves.
Short-List of Mandatory Requirements for "Installable Web-APK":
(As we could not find a full List, i try to include all Points)
Registered Service-Worker (default-implementation like yours is enough)
manifest.json (yours is valid)
https with valid certificate
https default-port (443, eg. https://yourdomain.com/test/)
... for the rest just check chrome audit tool (HINT: you don't need to pass all requirements - your web-apk should work when switching to https-default-port)

Acces a complex json object in Ionic 3 and bind to view

I making an Ionic 3 app. I have the following JSON object:
{
"player": {
"username": "thelegend",
"platform": "xbox",
"stats": {
"normal": {
"shots": 5,
"wins": 66
},
"hard": {
"shots": 5,
"wins": 77
}
}
}
}
I want to acces the following data from the JSON object:
stats: {normal:{ shots: "58", wins: "54"}, hard: {shots "34", wins: "43"}
This is my rest provider method in my Ionic 3 app:
getStats(){
return this.http.get(this.apiUrl).subscribe(data => {
console.log(data);
});
}
I call this method at a specific page:
ionViewDidLoad() {
this.getData();
}
getData(){
return this.results = this.rest.getStats();
}
The api is working great and I can see the data in my Chrome developer tools. Now I want to bind this data on the view like this:
<ion-card>
<ion-card-header>
Wins
</ion-card-header>
<ion-card-content>
{{results}}
</ion-card-content>
</ion-card>
When I run the app it shows [object object]. I tried {{results.player.stats}} but it didn't work.
How can I bind the stats values on my view and access this?
Kind regards
you need to convert http response to json:
getStats(){
return this.http.get(this.apiUrl).map(res => res.json()).subscribe(data => {
console.log(data);
});
}
The api that I used is not working properly I changed to another api and everything was working fine. Thanks for the help!

error page occurs while accessing buy link of Google books API result

i am doing a bar code scanner application.I am trying to get Google book details from the bar code ISBN number in android application. Also i got all the book details from API result successfully. But if i try to access the buy link from API result, i am unable to access the buy link of the book. It says 404 error. Can anyone help me, how to access the buy link to buy a book.? Thanks in advance.
Here is the buy link of book got from below result:
http://books.google.co.in/books?id=xqxBtXmxqV4C&dq=isbn:9781849699327&hl=&buy=&source=gbs_api
Here is the API result:
"saleInfo": {
"country": "IN",
"saleability": "FOR_SALE",
"isEbook": true,
"listPrice": {
"amount": 162.0,
"currencyCode": "INR"
},
"retailPrice": {
"amount": 113.4,
"currencyCode": "INR"
},
"buyLink": "http://books.google.co.in/books?id=xqxBtXmxqV4C&dq=isbn:9781849699327&hl=&buy=&source=gbs_api",
"offers": [
{
"finskyOfferType": 1,
"listPrice": {
"amountInMicros": 1.62E8,
"currencyCode": "INR"
},
"retailPrice": {
"amountInMicros": 1.134E8,
"currencyCode": "INR"
}
}
]

Using paypal express checkout in Android

I want to use paypal express checkout in paypal to get the token ID to send the ID to the server. At the moment I am using the general paypal and I get a response like this:
{
"payment": {
"short_description": "Coffee Payment",
"amount": "24",
"currency_code": "AUD"
},
"client": {
"platform": "Android",
"paypal_sdk_version": "1.2.3",
"product_name": "PayPal Android SDK; ",
"environment": "sandbox"
},
"proof_of_payment": {
"adaptive_payment": {
"timestamp": "2014-03-26T03:22:09+0000",
"payment_exec_status": "COMPLETED",
"app_id": "APP-80W284485P519543T",
"pay_key": "AP-6N7046464K788532B"
}
}
}
But I need to get the token using paypal express. I would greatly appreciate if the way to do this can be shown.
That sample is using Adaptive Payments. The Express Checkout portion of the REST CreatePayment API is what you're after.
i have done implementation. If you have read the docs in the paypal developer page, the only problem you should be having is generating the access token. The access token is generated as follows:
<?php
require_once ("include/braintree_init.php");
require_once 'vendor/braintree/braintree_php/lib/Braintree.php';
/*if(file_exists(__DIR__ . "/../.env")) {
$dotenv = new Dotenv\Dotenv(__DIR__ . "/../");
$dotenv->load();
}*/
$clientToken = $gateway->clientToken()->generate();
$output = json_encode(array("response" =>$clientToken)) ;
echo $output;
After send the output to your android. And that's it. But you will have to have the include files that i have included.

Categories

Resources