Send Parameter View Modal to App-Delegate File (Xamarain) - android

I am a Xamarin developer I implement app switching in my project and it's done for the android version but I don't have an idea how to do it for the IOs version
When I use the open URL function in my view controller it's working
~if(Device.RuntimePlatform == Device.iOS)
{
try{
var param = new NSDictionary();
UIApplication.SharedApplication.OpenUrl(new NSUrl("URL that want to pass"), param, (completed) =>
{});
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString(), "123456");
}
}
}~
but when the app-center built APK for the android it's failed and getting me an error cause of the UIKit library
So I want to pass the parameter(Deeplink URL) from my view modal to App-Delegate File but I am not to much aware about the xamarin so I am not able to do this

Take a look at Xamarin.Essentials: Launcher.
You can use Launcher class directly in Forms project to open a URI, this is often used when deep linking into another application's custom URI schemes.
Sample
var supportsUri = await Launcher.CanOpenAsync("lyft://");
if (supportsUri)
await Launcher.OpenAsync("lyft://ridetype?id=lyft_line");
In iOS 9 and greater, Apple enforces what schemes an application can query for. To specify which schemes you would like to use, you must specify LSApplicationQueriesSchemes in your Info.plist file.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>lyft</string>
<string>fb</string>
</array>

Related

Download Word .docx as Blob file from Angular on mobile devices

I am trying to download .docx file from REST API (.NET Core FileContentResult) in Angular application. Everything is working fine on PC, but there is problem with downloading .docx files in VMware Workspace ONE Web browser (didn't try standard browsers like Chrome or Safari, it looks like there is just Android WebView). It is company application and this browser is the only one allowed.
The problem is only with .docx files. Files like PDF, .doc and .xlsx (created by ClosedXML) are working fine.
REST API call (also tried with 'arraybuffer' instead of 'blob' and created Blob object in client, but problem persists)
this.httpClient.get(requestUrl, {
responseType: 'blob',
observe: 'response'
});
Then I save response body with FileSaver.
generateDocument(file: string | Blob, name: string): void {
FileSaver.saveAs(file, name);
}
I also tried approach that creates link and click on it (it does not work).
Solution with using window.open(blobUrl) is not working.
EDIT:
I got information that it is not working at all in iOS with same browser. Users get error message "Link is invalid."
Can someone help me with this issue? Thanks.
If you can retrieve obtain an ArrayBuffer, this could be used to initiate the download with those bytes:
Test here: https://batman.dev/static/70085191/
async function downloadUrl(url) {
downloadBuffer(
await (await fetch(url)).arrayBuffer()
)
}
function downloadBuffer(arrayBuffer) {
const a = document.createElement('a')
a.href = URL.createObjectURL(new Blob(
[ arrayBuffer ],
{ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
))
a.download = 'my-file.docx'
a.click()
}

Android Creative SnapKit: Photo with attachment Url pop-up opens twice

I am trying to share Image on SnapChat with attached URL generated from Branch IO. For that I have used Creative SnapKit.
When I clicked on the attached link, it gives me two pop-ups.
First pop-up redirects me to Playstore
The second pop-up redirects me to the installed app.
Ideally, if an app is installed then it should only give a single pop-up which redirects to the App.
I am using the following version:
implementation([ 'com.snapchat.kit.sdk:creative:1.6.3', 'com.snapchat.kit.sdk:core:1.6.3' ])
Implementation:
snapCreativeKitApi = SnapCreative.getApi(getActivity());
snapMediaFactory = SnapCreative.getMediaFactory(getActivity());
SnapPhotoFile photoFile;
try {
photoFile = snapMediaFactory.getSnapPhotoFromFile(fileName);
} catch (SnapMediaSizeException e) {
e.printStackTrace();
return;
}
SnapPhotoContent snapPhotoContent = new SnapPhotoContent(photoFile);
snapPhotoContent.setAttachmentUrl(urlToShare);
finish();
snapCreativeKitApi.send(snapPhotoContent);
AndroidManifest.xml
<meta-data android:name="com.snapchat.kit.sdk.clientId" android:value="ClientID" />
We are using same keys for iOS and Android. For iOS, it's working as expected.
Please let me know if I am doing anything wrong here.
Here is the video link for the issue I am facing:
https://www.dropbox.com/s/ivpshfs9o15kivr/20-08-20-10-32-07.mp4?dl=0
Finally, I found the solution & it was because of Branch IO configuration:
I have changed the configuration > DeepView Manager > Branch Default Bridge Template.
I put Canonical Identifier and Canonical URL as mentioned in the documentation.
For more information, read below Branch IO documents:
https://help.branch.io/using-branch/docs/deepviews
https://blog.branch.io/branch-concepts-the-branch-universal-object/

Custom Tabs Support Library

Recently was added this support library, but I couldn't find any example.
What the purpose of this library?
Could you post any example using this library?
CustomTabs is used to open links in a browser that supports CustomTabs. Most likely opening is done on Chrome, hence CustomTabs is part of chromium platform.
Purpose is to avoid implementing WebViews in your application and yet giving you option for styling actual chrome tabs, like toolbar color, title, various exit/enter transition, adding action buttons and menues. CustomTabs will allow your application bind to the chrome service and make chrome work as part of your application. Styling which will give you feel the opened web resource is part of your application.
Beside the styling, CustomTabs will give you full chrome web capabilities that probably couldn't be achieved with standard WebView.
Here are demos, which are straight forward.
Edit:
A snippet from my application which is "simplified" version of the Google's demo, lacking fallback mechanism, for now.
Usage of the helper is the following:
Initialize it when your activity is alive
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview);
mCustomTabHelper = new SimpleCustomChromeTabsHelper(this);
}
2. When the instance is alive and we have an url ready to be opened we can call:
mCustomTabHelper.prepareUrl(mProduct.getRedirectUrl());
Which will bind to the Chrome service, if not previously bind, or will just notify Chrome service that we might be opening that link in the future.
CustomTabSession can be used to open or prepare multiple url.
Open the url
mCustomTabHelper.openUrl(mProduct.getRedirectUrl());
The overloaded method of openUrl is using sort of ui options builder that is replica of the CustomTabIntent.Builder, but I have dropped the CustomTabsSession argument so the helper later will build CustomTabIntent internally.
I'm running Chrome Dev version along stable one. If I choose the stable one, I'm not able to use CustomTabsat all. As Google advices, CustomTabs will only work on Chrome 45 and beta versions of Chrome.
Demo from my application: https://youtu.be/fnIZwuJXjHI
Edit: Post
Try this:
gradle dependency:
dependencies {
...
compile 'com.android.support:customtabs:25.1.0'
}
Code :
Uri uri = Uri.parse("https://github.com/mzelzoghbi");
// create an intent builder
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
// Begin customizing
// set toolbar colors
intentBuilder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
intentBuilder.setSecondaryToolbarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
// build custom tabs intent
CustomTabsIntent customTabsIntent = intentBuilder.build();
// launch the url
customTabsIntent.launchUrl(activity, uri);
There is demo project on github, mentioned by #NikolaDespotoski, which can be partially reusable.
Solution is based on this article.
Add project shared to your project. Shared is a name of project (I don't know why Google didn't add it into customtabs library). link to shared project
Copy Activity helper from demo project to your project and put correct package. CustomTabActivityHelper
To pre-fetch url use CustomTabActivityHelper#mayLaunchUrl method (if needed) and CustomTabActivityHelper#openCustomTab to open Chrome custom tab.
For instance openning custom tab:
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
CustomTabActivityHelper.openCustomTab(this, customTabsIntent, uri,
new CustomTabActivityHelper.CustomTabFallback() {
#Override
public void openUri(Activity activity, Uri uri) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
Pre-fetching of url is more complicated. You can see this demo for better understanding.

Best way to display a Images and Doc files from base64-string - Android and Blackberry

I am trying to display image,docs from base64-string for Android and IOS. I am using inapp browser plugin to display image and doc files in app.
For IOS i am able to display images using below code.But facing issue with Android and Blackberry.
window.open(urlData, "_blank", "location=no,enableviewportscale=yes");
I am passing urlData parameter as base-64 string. Android and Blackberry nothing is displaying. After searching i found this post.
Alternative: just store that whole data string in your database. Then when you render your tag you can simply dump it into the src
attribute:>" />
After inserting above code i am able to display image but how to close the image ? How to open image in popup ? So user can close the image.
Thanks
First, window.open probably isn't working because all URLs have to be granted access specifically, for security. You can try to bypass it with this in your config.xml -- I don't know if it will work for data: URLs.
<access origin="*" subdomains="true"/>
<preference name="WebSecurity" value="disable"/>
If this doesn't work, how to show an image in a pop-up comes down to the design of your app. If you're using something like Ionic Framework, Bootstrap, jQueryUI, or Ratchet, they each have components for Modals or Dialogs you could potentially use. If you're not using a UI framework, you'll have to design your own pop-up div to contain the image tag, that is hidden again when you tap or dismiss it. Finding information on Google about how to do this is not very hard.
Good luck!
I am able to solve this issue in BlackBerry using below steps.
1)Remove webWorks.js from index.html
2)Replace below script inside index.html
<script src="worklight/cordova.js"></script> to <script src="../../cordova.js"></script>
3) Add below code inside js file. Need to pass urlData as Base64 string and filename.
requestFileSystem(LocalFileSystem.PERSISTENT, 7 * 1024 * 1024, function (fs) {
var ft = new FileTransfer(),
localPath = fs.root.toURL() + fileName;
ft.download(urlData, localPath, function (entry) {
entry.file(function (file) { console.log(file.size); });
window.open(localPath, "_blank", "location=yes,closebuttoncaption=Close,enableViewportScale=yes");
}, function (e) { console.log('download error'); console.log(e); });
});

Embed PDF Viewer for PhoneGap application

How can I embed a PDF viewer for a phonegap application? I have decided to use PhoneGap + Sencha Touch to develop an application for iOS and Android.
I only have iOS phonegap experience. The solution that has worked for me is to make a plugin that pops up a native webview that uses iOS native pdf viewer. The way to get this to work is to follow the instructions on this website.
http://spin.atomicobject.com/2010/12/07/updating-phonegap-s-childbrowser-plugin-to-handle-local-files/
This link modifies an existing plugin, "Child browser" to use the native webview display pdf's. The original chilbrowser plugin can be found here.
To give you more of an idea of what it will be like, here is my particular javascript call that I put into my sencha application.
PhoneGap.exec("ChildBrowserCommand.showFilePage", GlobalVar.localRoot + "/" + record.get("FilePath"));
This is inside the handler for the buttonTap inside the sencha, pressing the button will then call the objective C method "showFilePage". The parameter is the filepath that the plugin will use.
Here is the Objective C part (again, you should follow the links for full instructions)
- (void) showFilePage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url
{
NSLog(#"showFilePage entered: ");
if(childBrowser == NULL)
{
childBrowser = [[ ChildBrowserViewController alloc ] initWithScale:FALSE ];
childBrowser.delegate = self;
}
PhoneGapViewController* cont = (PhoneGapViewController*)[ super appViewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
[ cont presentModalViewController:childBrowser animated:YES ];
NSString *path = (NSString*) [arguments objectAtIndex:0];
NSLog(#"Our argument 0 is: %#",[arguments objectAtIndex:0]);
NSLog(#"The url is: %#",path);
[childBrowser loadFileURL:path];
}
There's not much documentation for mixing PhoneGap and ObjC, but here is some example code that lets you embed PhoneGap with an ObjectiveC-Application. For the PDF viewer, you can either use basic ones like Apple's QuickLook or UIWebView, or more advanced ones like PSPDFKit.
For Android, you could simply search for an Intent that is capable of displaying pdf (like Adobe's official Reader for Android) or integrate a full PDF viewer yourself. There's an open source project for that, but it looks not quite complete. Or check out apv, or droidreader, which is GPLv3.
Hi just use HTML5 object tag, you can add,swf, pdf etc..

Categories

Resources