Titianim app Ti.Android.currentActivity is undefine - titanium

I am new to Titanim Development. Now I am working with a existing app. The app seems to developed with the 3.0.2 version but I configured my system(OSX maverick) with latest version(3.2.3).
source:
Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
url: '/app/ui/WindowEula'
}));
When I build and run the application the application through error in the above line
Ti.Android.currentActivity is undefine.
How to fix this error.

try this :
var activity = Titanium.Android.currentActivity;
activity.finish();
use currentActivity instead of CurrentActivity.

Related

CodePush not updating new version

I have version 5.0.1 of my application with two versions released on CodePush.
I do not bump up any Version or Build numbers. So 5.0.1 and Build 1.
The first version v1 gets installed, but after I make a new release (v2), the bundle doesn't get downloaded or installed anymore.
v1:
v2:
I use the following to add CodePush to my app:
const CodePushHomeScreen = codePush(HomeScreen);
Thanks
Default behavior restricts updates to only occur once an app is restarted. I would first confirm that updates aren't being registered after a restart of the app and/or switch things over to update on resume instead using this snippet:
let codePushOptions = { checkFrequency:
codePush.CheckFrequency.ON_APP_RESUME };
class MyApp extends Component {
}
M HomeScreen App = codePush(codePushOptions)(HomeScreen);
If that doesn't work, delete the two updates and release two more using the flag:
--targetBinaryVersion "~5"

Unable to resolve module `url` from [path]/node_modules/ws/lib/WebSocket.js

I created a new React Native v 0.42.0 project with the following libraries installed.
react-native-ble: 1.0.8
bleat: 0.1.1
In addition to the welcome page. I added the two following lines to load the bleat and noble and an remote android tablet.
var noble = ('noble');
var bleat = require('bleat').classic;
Noble loads correctly, but everytime I try to include the bleat library I get this error.
==============================================
The development server returned error code: 500
URL: http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false
Unable to resolve module url from [path]/node_modules/ws/lib/WebSocket.js
Module does not exist in the module map or in these directories
/node_modules/
===============================
I'm not quite sure how to fix this issue.
I found my answer to this issue to be inserting this line into my package.js file.
"browser": {
"noble": "react-native-ble"
}

Titanium ACS issue

trying to create an ACS server using Titanium Studio. Following the example of pixgrid (https://github.com/appcelerator/pixgrid/), but always get an error when trying to run locally; console output:
[INFO] Installing dependencies...
[INFO] Dependencies installed.
[INFO] socket.io started
[ERROR] Error occurred. TypeError: Cannot call method 'init' of undefined
at Object.start (/app.js:8:7)
app.js listing:
var ACS = require('acs').ACS,
logger = require('acs').logger,
express = require('express'),
partials = require('express-partials');
// initialize app (setup ACS library and logger)
function start(app) {
ACS.init('***', '***');
logger.setLevel('DEBUG');
//use connect.session
app.use(express.cookieParser());
app.use(express.session({ key: 'node.acs', secret: "secret" }));
//set favicon
app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
//set to use express-partial for view
app.use(partials());
//Request body parsing middleware supporting JSON, urlencoded, and multipart
app.use(express.bodyParser());
}
// release resources
function stop() {
}
Ofcourse I have my OATH key and secret at the ***. Same when running from command line (acs run).
I am running Titanium Studio, build 3.4.1.201410281727.
I can however publish the service, and then run it from the cloud without any issues. For development this is not ideal, so want to run it locally (local node.ACS server).
I guess there must be something wrong with where things are installed (only used default), or permissions. Anyone that got a clue how to fix this? Have spent some hours now searching the internet, but seem to be the only one with this exact problem. No clue what else to try.
Thanks for reading this far. If you require more information to help me, let me know.
Ok, I found the problem. They changed the way to use ACS in the last upgrade.
Classic mode was:
var ACS = require('acs').ACS;
ACS.init('<ACS Key>', '<ACS secret');
Now they changed it and ACS is a "module", like any other one, so you must use the new way. In the package.json file add it as a dependecy:
"dependencies": {
"acs-node": ">=0.9.2"
}
Install it: npm install acs-node
Now you can use it in its new format, on the app.js file:
var ACS = require('acs-node');
ACS.init('<App Key>');
It's all explained here: http://docs.appcelerator.com/cloud/latest/#!/guide/node_acs

Function based off of app version in package.json

I would like to run a function based of the version of my node-webkit app from the package.json file. How do I get this version number?
I'm not talking about:
process.versions['node-webkit'];
Which just shows the node-webkit version.
You can get the manifest as an object in nw, using App. Just extract the version there:
var gui = require('nw.gui');
var myAppVersion = gui.App.manifest.version;
See also https://github.com/rogerwang/node-webkit/wiki/App#manifest

E2E Testing for AngularJS App on another computer

I'm developing single page application on AngularJS for learning. My project is located on Apache HTTP Server on another computer, I use WinSCP synchronisation while developing so that it is always the last version of my work.
Halfway through (actually, when I has already finished the biggest part the application), I realized that I don't have any tests and I should learn how to test what I do not just manually. I decided to try writing E2E tests for my AngularJS application using Karma Test Runner.
I installed Karma via npm, initialized it (karma init test/karma.conf.js), but what happens now?
I tried karma start test/karma.conf.js it launches Chrome (as I stated in config) and says that
Karma - connected
Chrome 26.0 (Windows) is idle
even though in conf file there are specified my test file:
files = [
'test/first_test.js'
];
And that's what inside it:
describe('my app', function() {
browser().navigateTo('/');
it('should then be.', function() {
expect(browser().location().url()).toBe('/login');
});
});
Thanks in advance!
EDIT: I realized, it's not just 'Chrome is idle', there's also console log error:
Uncaught ReferenceError: browser is not defined
Any ideas? I'm so confused right now.
Browser is only defined inside of beforeEach. Try this:
describe('my app', function() {
beforeEach(function(){
browser().navigateTo('/');
});
it('should then be.', function() {
expect(browser().location().url()).toBe('/login');
});
});
Alright, looks like I solved it myself.
I should have added
ANGULAR_SCENARIO,
ANGULAR_SCENARIO_ADAPTER,
to the files property of karma config file. After that, I progressed a little bit, but still got a lot of troubles, but essentially the main was that I got error that resumeBootstrap was undefined. My app was using AngularJS 1.0.4, but it looks like Karma's Adapters are for 1.0.6+ only. Upgrading app to 1.0.6 helped with resumeBootstrap.
Regarding testing the app on external server:
proxies = {
'/': 'http://another.internal/app/'
};
and don't forget to change links to CSS and JS files in app's index.html from local (css/style.css) to web (//another.internal/app/css/style.css).