Cordova 3.0.0 ActionSheet plugin for ios not working properly - iphone

I have installed cordova 3.0.0 version for ios recently and trying to create ActionSheet plugin for ios.
Now, My problem is when tap on button nothing happens means Actionsheet does not open.
It works fine in simulator but in device
when i double press home button then only actionsheet displays. it is working fine in cordova 2.9.0.
I have also checked Datepicker plugin in this the same issue happens.
my code is given below:
var actionSheet = cordova.require("cordova/plugin/actionsheet");
var options = {
title: 'MyTestApp',
items: ['Open gallery','Cancel']
};
options.visibility = "auto";
options.onDismiss = openActionsheet;
actionSheet.show(options);
Please help me with that....

I finally found the solution.
Place .h and .m file in Plugins folder. Now create plugins folder in www and ActionSheet.js file in that www/plugins/ActionSheet.js folder.
Add below line to Config.xml
<feature name="ActionSheet">
<param name="ios-package" value="ActionSheet" />
</feature>
Now you have config_plugin.js file in your www folder place below code in this file:
{
"file": "plugins/ActionSheet.js",
"id": "ActionSheet",
"clobbers": [
"actionSheet"
]
}
now you can call actionsheet method as below:
var options = {
title: 'Blownaway',
items: ['Open gallery','Cancel']
};
actionSheet.show(options);
No need to include ActionSheet.js in Script tag in html file for ActionSheet.js.
You can directly call actionSheet.show method.

Related

Redirect to view in other image folders using ImagePicker plugin in android (Ionic 3)

I am using the image picker plugin in my Ionic app. I want able to pick images from other folders from the gallery in android device. For Ios it is possible but for android I am getting this view.
But I want user able to go to other folders and select images from it. Any help would be great.
I supose you are using cordova plugin File. If you want select others routes, u can use the diferents directories provided by File. EJ:
this.file.applicationStorageDirectory
this.file.applicationDirectory
this.file.documentsDirectory
You have the complete list here https://github.com/apache/cordova-plugin-file
If you need more help, say to me.
to use if With Filepicker use a constant to set options:
const options = {
title: 'Select Avatar',
customButtons: [{ name: 'fb', title: 'Choose Photo from Facebook' }],
storageOptions: {
skipBackup: true,
path: 'images',
},
};
and send it to the picker:
ImagePicker.showImagePicker(options, (response) => {

what's happens with transition pages in iPhone

why i having a problem in the iPhone but android work good
problem usually occurs between the pages in IOS
for example :
when go to other page usually go and back in the same time without click the back button .
You should use the fix recommended by Ionic team:
https://gist.github.com/IgorMinar/863acd413e3925bf282c
Place downloaded file into www/js folder.
Add script tag in index.html: <script src="js/ngIOS9UIWebViewPatch.js"></script>
Add new dependency in app.js: angular.module('myApp', ['ngRoute', 'ngIOS9UIWebViewPatch'])
More info about that bug: http://blog.ionic.io/preparing-for-ios-9/

Firefox add-on Action Button has no icon

I added this code to my Add-on SDK extension in the index.js:
var button = ActionButton({
id: "my-button",
label: "my button",
icon: {
"16": "./us16.png",
"32": "./us32.png"
},
onClick: firstClick
});
The Action Button gets added just fine and works, but there is no icon showing. I put the two icon files in the root folder of my add-on. Should I have put them elsewhere?
(Button documentation.)
Yes. Put your icons in data folder, whilst leaving the paths in the code as they are now.
I have same problem. And solution is add this code to packet.json
"permissions": {"private-browsing": true}
see here Firefox SDK Sample Add On Exported XPI Action Button Doesn't Show Up

CDVPlugin class ChildBrowserCommand (pluginName: ChildBrowserCommand) does not exist

I have created a PhoneGap based application and included the same code I have downloaded from this link: Building PhoneGap Mobile Applications Powered by Database.com
When I run the app I am able to see login screen. Here is the screenshot:
When I click on Login button nothing is happening, I am in the same page. I have already included my cosumer key in salesforceWrapper.js file like this:
function SalesforceWrapper() {
/* AUTHENTICATION PARAMETERS */
this.loginUrl = 'https://login.salesforce.com/';
this.clientId = 'sadsadasdadadasdasdasdsadasdas.dsddsd_sdsds.dsdsdsdsdsds';
this.redirectUri = 'https://login.salesforce.com/services/oauth2/success';
/* CLASS VARIABLES */
this.cb = ChildBrowser.install(); //ChildBrowser in PhoneGap
this.client = new forcetk.Client(this.clientId, this.loginUrl); //forceTk client instance
this.init();
}
Why am I unable to redirect to salesforece login page? Here is the console output:
2012-06-25 16:20:53.023 J[2396:13403] Opening Url : https://login.salesforce.com/services/oauth2/authorize?display=touch&response_type=token&client_id=sadsadasdadadasdasdasdsadasdas.dsddsd_sdsds.dsdsdsdsdsds&redirect_uri=https%3A//login.salesforce.com/services/oauth2/success
2012-06-25 16:20:53.024 J[2396:13403] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> Application tried to present modally an active controller <MainViewController: 0x9a67dc0>.
2012-06-25 16:20:53.034 J[2396:13403] ERROR whitelist rejection: url='https://login.salesforce.com/services/oauth2/authorize?display=touch&response_type=token&client_id=sadsadasdadadasdasdasdsadasdas.dsddsd_sdsds.dsdsdsdsdsds&redirect_uri=https%3A//login.salesforce.com/services/oauth2/success'
Added ChildBrowserCommand and ChildBrowser fields to Cordova.plist.
Included the script file path in Index.html page:
<script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script>
and here is my Xcode project screenshot:
I have solved CDVPlugin reference issue and got the WebKit discarded an uncaught exception issue. How can I solve this?
Solved it by adding extra parameter to ExternalHosts in Crodova.plist.
For anyone else that is facing this issue,
The problem is perhaps due to the fact the event handlers are not properly bound. - Or bound more than once (most probably).
While a patch has to be done on the plugin code to prevent it from trying to bind more than once, a simple way to prevent this happening is to use a delegated event handler in jQuery and ensure the event is bound to the target exactly once.
Have you edited the Cordova.plist file to include the mapping required for the ChildBrowser plugin?
Have you included the .h .m source code for the ChildBrowser plugin correctly in your project?
Have you included the childbrowser.js file, and loaded it into your index.html file?
It's normally one of these issues that causes the problem.
For everyone else having this issue on IOS 5, the issue is that Childbrowser is trying to displaye twice which causes the error. One solution is to throw a try catch around the display code.
i.e. change this (ChildBrowserCommand.m -> showWebPage)
#ifdef CORDOVA_FRAMEWORK
CDVViewController* cont = (CDVViewController*)[ super viewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
childBrowser.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[ cont presentModalViewController:childBrowser animated:YES ];
#endif
To This:
#ifdef CORDOVA_FRAMEWORK
CDVViewController* cont = (CDVViewController*)[ super viewController ];
childBrowser.supportedOrientations = cont.supportedOrientations;
childBrowser.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
#try {
[ cont presentModalViewController:childBrowser animated:YES ];
}#catch(NSException * e){
NSLog(#"ALready visible");
}
#endif

iOS on resume not working

I need a view in my app to refresh everytime the app comes back to the foreground. The code below is working perfectly with Android but nothing happens on iOS.
$ionicPlatform.on('resume', function() {
if($state.current.name == "app.listar_aprovacoes"){
// code to refresh scope and view.
};
});
I also tried the following and it also doesn't work with iOS:
document.addEventListener("resume", function() {
var alertPopup = $ionicPopup.alert({
title: 'Foo',
template: 'Bar'
});
}, false);
So could you help me out with a solution to this problem?
Thanks!
EDIT: For some reason, updating the platform using ionic platform update ios didn't update the code for this. I removed the platform and added it again and it started working.
Try using window.addEventListener('resume', callback); as well.
Also make sure you have the Cordova Device Plugin.
You can install it by using:
ionic plugin add cordova-plugin-device
Generally, with the plugin installed, the first ($ionicPlatform.on('resume', ...)) method should work. I tested both on iOS and Android.
For some reason, updating the platform using ionic platform update ios didn't update the code for this. I removed the platform and added it again and it started working.