Titanium Ti.Android Undefined in ios - ios

I am very new to Titanium Developer. I assigned an Titanium project for made UI changes to latest ios look and feel. When I run App I will always throwh exception like Ti.Android is undefined.
The previous version of the SDK is 3.0.2 but I am now configured the latest version 3.2.3GA
Current the app run without any error in Android only show error as undefined for Ti.Android in Ios only.
My Dough whether Ti.Android is strict to Android platform only or its for both ios and android or else its is deprecated for ios in latest version.
Please help.

As is mentioned in the docs Ti.Android is available only for Android (Ti > 1.5, see the logo on the right) http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Android however if you try to access only Ti.Android it should work and return undefined because Ti has no Android property. You shouldn't see any errors... ,but you are probably trying to access some other property for instance Ti.Android.XXX which obviously can't work.

You should check the platform first before using any platform-specific modules/function. You could add a function on your commonjs to check it.
var osname = Ti.Platform.osname;
function isAndroid() {
return osname === 'android';
}
function isIOS() {
return osname === 'iphone' || osname === 'ipad';
}
function isMobileWeb() {
return osname === "mobileweb";
}
On your controller, you then do something like this:
var fn = require('commonjs');
if (fn.isAndroid()) {
//the things you do for android only
} else if (fn.isIOS() {
} else if (fn.isMobileWeb()) {
}

Related

Sending boolean value on flutter platform method channel not working correctl on iOs

I added some iOs and Android native code to Flutter application. Function that is natively called returns a boolean value as:
Future<bool> get isOn => _channel.invokeMethod('isOn').then<bool>((d) => d);
On Android everything works correctly. In the method call handler of the channel I return a boolean as:
...
case "isAvailable":
{
result.success(myFuncThatReturnsTrueOrFalse());
break;
}
...
On iOs I have a similar handler and it always returns true:
if ([#"isOn" isEqualToString:call.method]) {
result(#(TRUE));
}
But when I run the dart isOn function on iOs i get an error about conversation of the bool and int value as:
type 'int' is not a subtype of type 'FutureOr<bool>'
I checked multiple plugins and they all do the bool stuff in the same way. Am I missing something somewhere?
I am running the latest stable flutter version (1.2.1), latest XCode (10.2.1) and the latest Android Studio (3.4).
change #(TRUE) to #(YES) would do it.

getting Value of type 'Set' has no member 'compactMap' FBAcessToken

var grantedSwiftPermissions: Set? { return (permissions?.compactMap { $0 as? String }.map { Permission(name: $0) }).map(Set.init) }
What is wrong in above code, Can you please help
This is probably due to your Xcode version,
Currently you are using xCode version <= 9.2 which support flatMap.
In FBCorekit library they included compactMap, which was introduced in xCode v 9.3.
So update your Xcode or use old library of Facebook.
Hope this will work.
If I am wrong or can be correct more than please welcome.

Cannot build source in XCODE 8 iOS 10

I have developed iOS application using Swift 2.3. and I have put the application to the app store in review process, apparently they have rejected it due to crash in iOS 10 .
Then in order to fix it I have downloaded the Xcode 8 and tried to build the app without converting code in to swift 3 using legacy setting
But I couldn't build the app. There was few compile errors in pods that I have used. (Alamofire framework)
error :- and there will more
private func trustIsValid(trust: SecTrust) -> Bool {
var isValid = false
var result = SecTrustResultType(kSecTrustResultInvalid)
let status = SecTrustEvaluate(trust, &result)
if status == errSecSuccess {
let unspecified = SecTrustResultType(kSecTrustResultUnspecified)
let proceed = SecTrustResultType(kSecTrustResultProceed)
isValid = result == unspecified || result == proceed
}
return isValid
}
So I did a small digging apparently Alamofire has released a new version for Xcode 8 so i have put that version, apparently I can't integrate that version in to my source code since it's in Swift 2.3.
Can someone help me to get over with this issue, problem was I can't release the app to App store since there is a crash in iOS 10 and I can't check it since I don't have iOS 10.

How can I set the default device to emulate in Ionic?

I'm using Ionic to build an iOS app. Right now I'm testing how it behaves in an iPad 2, but doing this requires me to constantly need to write:
ionic emulate ios --target="iPad-2"
Is there a way to hard-code this somewhere in the ionic.project file or somewhere else so I can stop manually doing this? Thanks
I was going through the same issue and even though this question is a year old but it was the first thing I got through google and couldn't find the answer anywhere else. Here's what I did just because I don't want to use --target="iPhone-7" everytime.
To be clear for anyone who lands here wanting to just run on a specific ios device use the following:
ionic run ios --target="iXXX-X"
The iXXX-X would be one of the names you get from running
ios-sim showdevicetypes
for example:
ionic run ios --target="iPhone-7"
I wanted to have a solution to make iPhone-7 my default, so running the following would target iPhone-7 (My original default target is iPhone-SE):
ionic run ios
It seems like the default is hardcoded and so must be changed in the code.
I found this file: /platforms/ios/cordova/lib/run.js
In there you'll find a function called deployToSim, I changed it as follows:
function deployToSim(appPath, target) {
// Select target device for emulator. Default is 'iPhone-6'
if (!target) {
return require('./list-emulator-images').run()
.then(function(emulators) {
if (emulators.length > 0) {
target = emulators[0];
}
emulators.forEach(function(emulator) {
// this is the original condition
// if (emulator.indexOf('iPhone') === 0)
// change "iPhone" to the specific model you want, in my case it's iPhone-7
// Notice the comma in iPhone7, without comma it will take iPhone-7-plus instead
if (emulator.indexOf('iPhone-7,') === 0) {
target = emulator;
}
});
events.emit('log', 'No target specified for emulator. Deploying to ' + target + ' simulator');
return startSim(appPath, target);
});
} else {
return startSim(appPath, target);
}
}

phonegap plugin barcodescanner not working on iOS

We are developing application for phonegap (2.4.0) - iOS (6) and Android platforms. Our app is using BarcodeScanner plugin.
Plugin is working without any problems on Android, but we have detected some problems on iOS.
At first in the file CDVBarcodeScanner.mm CDVPlugin.h was not found, so we commented if/else check around this line: #import <CORDOVA/CDVPlugin.h> and to config.xml file we have added this line: <plugin name="org.apache.cordova.barcodeScanner" value="CDVBarcodeScanner" />
Then was build successfull without any errors, but after clicking on scan button nothing happened and nothing was written to output.
Then we compared barcodescanner.js for Android and iOS and found that after adding logs at the end of Android js file:
if(!window.plugins) {
console.log("something 1");
window.plugins = {};
}
if (!window.plugins.barcodeScanner) {
window.plugins.barcodeScanner = new BarcodeScanner();
console.log("something 2");
}
output was written after starting of application. In the case of iOS we have also added to similar part some console logs:
(function() {
if (!window.plugins) window.plugins = {}
console.log("something 1");
if (!window.plugins.barcodeScanner) {
window.plugins.barcodeScanner = new BarcodeScanner();
console.log("something 2");
}
else {
console.log("Not installing barcodeScanner: window.plugins.barcodeScanner already exists")
}
})
but no one was written.
Thanks for every advice.
We have tried these changes and plugin works:
we downgraded to phonegap 2.3
we set -O0 compile flags to zxing-all-in-one.cpp
checked all added libraries

Resources