Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6297] Please check the following bug i have found in SDK 8.1.0.v20190619134801

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionInvalid
Resolution Date2019-07-02T22:15:25.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
ReporterAndreas Pingas
AssigneeShak Hossain
Created2019-06-28T12:11:31.000+0000
Updated2019-07-02T22:15:26.000+0000

Description

Please check the following bug i have found in SDK 8.1.0.v20190619134801 Please us the attached code In the older SDK version i get the following: [INFO] : Ti.Platform.isIOS TEST 1 false [INFO] : Ti.Platform.isIOS TEST 2 false [INFO] : Ti.Platform.isIOS TEST 3 false at SDK SDK 8.1.0.v20190619134801 i get the following [INFO] : Ti.Platform.isIOS TEST 1 false [INFO] : Ti.Platform.isIOS TEST 2 undefined [INFO] : Ti.Platform.isIOS TEST 3 false

Attachments

FileDateSize
app.js2019-06-28T12:10:31.000+0000156
templates.js2019-06-28T12:10:33.000+0000196

Comments

  1. Joshua Quick 2019-06-28

    [~andreas.pingas], I'm not going to accept this as a bug. This was unfortunately intentional. Here is why... On Android, every JS file has its own "copy" of core Titanium modules such as Ti.Filesystem, Ti.Media, Ti.UI, etc. This is true even in older versions of Titanium. The negative consequence of this is that whatever methods/properties you add to that core Titanium module will not be available to any other JS file. This was an intentional design decision made on Android years ago to support file paths relative to a JS file that it was called in. I don't personally agree with it (doesn't match iOS' behavior), but that's how it works for now. The reason you're seeing this in Titanium 8.1.0 now is because we added relative path support to Ti.Platform.openURL() and Ti.Platform.canOpenURL(). For example, run the below code on both Android and iOS. The below will log if the core library references match between the "app.js" and "foo.js" scripts. Notice that it'll return false on Android for Ti.UI and Ti.Media on older SDK versions, but they return true on iOS. app.js
       var foo = require("foo");
       Ti.API.info("Do 'Ti.UI' modules equals? " + (Ti.UI == foo.TiUI));
       Ti.API.info("Do 'Ti.Media' modules equals? " + (Ti.Media == foo.TiMedia));
       
    foo.js
       exports.TiUI = Ti.UI;
       exports.TiMedia = Ti.Media;
       
    ---- What I recommend that you do instead is set up your own properties/methods in the "global" namespace. For example...
       global.MyGlobals = {
       	isIOS = true,
       };
       
    ---- Alternatively, if your goal is to simply identify the platform, then a simpler solution that works for a Classic Titanium app is to do the following...
       if (Ti.App.Android) {
       	// Do Android stuff...
       } else if (Ti.App.iOS) {
       	// Do iOS stuff...
       } else if (Ti.App.Windows) {
       	// Do Windows stuff...
       }
       
  2. Andreas Pingas 2019-07-02

    ok, thanks!

JSON Source