I am trying to display image selected from camera/gallery using cordova-plugin-camera plugin and used window.Ionic.WebView.convertFileSrc() for Rewriting file:// due to wkwebview.
It works fine in android platform but in iOS platform it gives error for Content Security Policy
For example I am getting
file:///Users/CN339/Library/Developer/CoreSimulator/Devices/XXXXXXX/data/Containers/Data/Application/XXXXX/Library/NoCloud/cdv_photo_002.jpg
from camera plugin and after using window.Ionic.WebView.convertFileSrc on previous local url I am getting below error.
Content Security Policy error
I tried a lot of methods to load local files such images or videos. I tried using
normalizeUrl (from ionic-angular)
regex and replace the local file path: path.replace(/^file:///, '')
window.Ionic.WebView.convertFileSrc()
None of above worked for me. The only way I could load a local file was using
window['Ionic']['WebView'].convertFileSrc(path);
Hope it works as you want. I have only tested it on Android
UPDATE
You can use win.Ionic.WebView.convertFileSrc(), like third bullet, only if you declare win: any = window.
To define win as any did the trick for me - https://stackoverflow.com/a/55934321/10243902
Just had the same problem on iOS after ionic-webview suddenly stopped working, so I uninstalled and reinstalled the plugin:
cordova plugin remove cordova-plugin-ionic-webview
cordova plugin add cordova-plugin-ionic-webview
window.Ionic.WebView.convertFileSrc started working like a charm again.
this.tempSchemeImagePath = window['Ionic']['WebView'].convertFileSrc(nativeURL);
Related
Use vscode to compile flutter app with webview on mac,run it in ios simulator,it's normal,
and I have added "io.flutter.embedded_views_previewYES" in ios's Info.plist,I am sure I have installed "webview_flutter" plugin,
but when I run it in xcode,always appears "Module webview_flutter_wkwebview" not found,
till now,I cound not solve the problem,please help,thanks!
https://github.com/fluttercommunity/flutter_webview_plugin/issues/657
I managed to make it work by opening Runner.xcworkspace instead of Runner.xcodeproj
I created new default tab project . I changed nothing. run the ionic serve no errors app opened in beowser its empty nothing.
After long investgation i found it opens the index.html inside src.
what happend why it is not lunching the real app.
I have ionic 5
It was a chrom problem. I had old version I upgrade it works fine. Looks old chrom dont understand type="model" for that it was nit downloading the js file
I am using two different share plugins in my flutter project. One plugin social_share_plugin and other is social_share . Both are used to share content on social media. Due to limitation of one plugin i have to use both. But i am getting 'Duplicate plugin key: SocialSharePlugin'error when i run the project on IOS device. it is working fine on android device.
var s = await SocialSharePlugin.shareToFeedFacebookLink(
quote: 'Meeting',
url: shareLink,
);
and other plugin is used like
await SocialShare.shareTwitter(
shareText,
hashtags: ["meetup"],
url: shareLink,
trailingText: '#meeting',
);
The issue is social_share uses the same class name as social_share_plugin (they both have SocialSharePlugin). To resolve this, I forked the social_share package and changed every instance of SocialSharePlugin to SocialShare, including the file names.
Here's my forked repo if you would like to use or view: https://github.com/kaarens93/social_share
(I have a lot of 'unresolved reference' errors that I'm still in the process of fixing but unless you want to build the package, you shouldn't run into any issues implementing into your project)
I ended up remove SocialShare completely from the project, and use flutter_share_me and SocialSharePlugin. I found Social_Share_plugin is the only one that works with Ins (and Facebook). None of the other packages worked in this aspect. However, with version 0.4 of SocialSharePlugin you need add Facebook api token to your info.plist file since the FBSDK used by SocialSharePlugin requires this token since version 13+. This change was not documented by 0.4 SocialSharePlugin.
So I'm using this plugin (https://github.com/katzer/cordova-plugin-local-notifications) for my app to have local notifications however it is not working when I have tested it.
I followed this tutorial https://devdactic.com/local-notifications-ionic/
I have tested the app on Ionic View on both android and iOS. I press the buttons but nothing shows up.
I have tried switching $cordovaLocalNotification with cordova.plugins.notification.local. when trying to use the functions in the plugin but that didn't work.
For what it's worth, the plugin does not show up in the package.json file but it does show up when I run the 'cordova plugins' command.
EDIT 1: The following is an image taken from my iPhone after I clicked Add notification
In my $ionicPlatform.ready(function(){...}), I have the following code
if(window.cordova && window.cordova.plugins.notification) {
alert('This alert doesn't fire');
}
The alert doesn't appear which means window.cordova.plugins.notification is unavailable just like the picture indicates
EDIT 2: On the ionic forums it was suggested that the plugin is not working on the Ionic View app as it is not one of the supported plugins. Please refer to: https://forum.ionicframework.com/t/katzers-local-notification-plugin/86748
However it does work when running/testing on a device(android) instead of the Ionic View app.
Add --save at the end of your command, something like:
cordova plugin add de.appplant.cordova.plugin.local-notification --save
It will add it to your config file.
Edit: Maybe you have error while using it. See error log by running the app with following command:
ionic run android -l -c
Finally running in the real device solved the issue.
I am trying to create a blackberry10 project with phonegap cordova command line tool. I am following through the phonegap document (http://cordova.apache.org/docs/en/2.9.0/guide_cli_index.md.html#The%20Cordova%20Command-line%20Interface) but keep running into the same problem.
When I run "cordova platform add blackberry10" in the terminal, it returns [Error: blackberry-nativepackager cannot be found on the path. Aborting]
Does anyone know why and what am I missing? Why is it trying to locate the blackberry-nativepackager, instead of the webwork sdk?
All I want to do its just loading up an external url in bb10. Any better suggestion? Does anyone has any good tutorial/walkthrough on how to create a blackberry10 project?
I'm pretty sure the nativepackager thing is needed to create a package, even with WebWorks. You'll find it in $BBNDK/host_10_x_xx_xxxx/linux/x86/usr/bin/blackberry-nativepackager (adapt to your OS). You'll need to add this folder to your path. Doing this depends on your OS.
The easiest way to do this is to run the bbndk-env script, located in your NDK root directory.
Here's some updated documentation to align with Cordova 3.0. It will cover all the steps needed (including the NDK setup, which seems to be currently missing in your environment).
http://cordova.apache.org/docs/en/3.0.0/guide_platforms_blackberry10_index.md.html#BlackBerry%2010%20Platform%20Guide