Friday, December 30, 2016

How to displays a back arrow on the home area of the action bar.

Here is the sample code. Please take a look

var win = Ti.UI.createWindow({
title : "Old Title",
navBarHidden : false
});
var actionBar;
win.addEventListener("open", function() {
if (Ti.Platform.osname === "android") {
if (!win.activity) {
Ti.API.error("Can't access action bar on a lightweight window.");
} else {
actionBar = win.activity.actionBar;
if (actionBar) {
actionBar.backgroundImage = "/bg.png";
actionBar.displayHomeAsUp = true;
actionBar.onHomeIconItemSelected = function() {
alert("Home icon clicked!");
};
}
}
}
});
win.open()


Check out this link as well 


Hope this helps.

Wednesday, December 21, 2016

Fixing npm permission for the Mac.

Just run this below command to do that

- npm config set prefix /usr/local
- sudo chown -R `whoami` /usr/local/

https://docs.npmjs.com/getting-started/fixing-npm-permissions

Hope this helps.

Android or iOS permission issue for the Appcelerator App.

Please have a look on this code sample, if you use any of that API then make sure the permission.
Thanks.

Invalid Request during running.


This is happening because of session expired. Just try this command via the terminal
  • appc logout 
  • appc login
Then run your app again. Hope this helps.

sqlite database store.

You will get it from the DDMS

DDMS-->Window-->Show view-->file explorer-->data--> data--> app package name-->databases 

Or Go to the tools folder of your Android SDK then click on "monitor"
Android Device Monitor> file explorer-->data--> data--> app package name-->databases
Hope this helps.

Install Appcelerator Studio to the Mac.


At first, download this node version and install it in your machine.


Then install the CLI via the terminal

sudo npm install -g appcelerator
appc use latest
appc setup
appc login 

Now take a fresh copy of Appcelerator Studio and install it in your machine. It will automatically install all other prerequisite software.


  •  https://web.appcelerator.com/product/studio

Hope this helps.

Appc command not found.

To the windows PC you can see that problem if the npm prefix is not on the PATH. Try running echo %PATH% and it should contain something similar to C:\Users\Ewan\AppData\Roaming\npm

 Try to set the path first then run the command

 SET PATH=C:\Windows\system32;%PATH%

      npm install -g appcelerator
      appc use latest
      appc setup


For the Mac

Run the command "npm config get prefix" and/or "npm get prefix" and make sure this refers to the default value /usr/local.

If it does not refer to the default value then run this command     

    npm config set prefix /usr/local

After Then run the following  command and let me know
      sudo npm install -g appcelerator
      appc use latest
      appc logout -D
      appc login 
      appc setup

Hope this helps.

How to change the android buildtools version in Appcelerator


You can change the build tools version using this command

appc ti config android.buildTools.selectedVersion ##.##.##

Example
appc ti config android.buildTools.selectedVersion 25.0.3

Just go to your Android SDK location. Here you will see the version number.

For mac location
/users/fokkezb/Library/Android/sdk/build-tools/ version_number

Hope this helps.

Saturday, December 17, 2016

Installing x86 Emulator Packages.



Maximum versions of the Android API are available with Intel x86 emulators. Look for the "Intel x86 Atom System Image" in the Android SDK Manager.
Go to the android SDK >>tools >> click on android and select all tools, Android-6, and Extra folder(Intel x86 emulator accelerator (HAXM)) then install those packages.
The x86 emulator may run faster than the standard ARM emulator, but may show minor differences with the ARM emulator. Extra software is required to take advantage of the x86 emulator – see Configuring Virtual Machine Acceleration in the Android Tools documentation. And the Extra software is Intel x86 emulator accelerator (HAXM).

Friday, December 16, 2016

Create new Android emulator.

Android default emulator is really very slow so create new x86 CPU based emulator

Go to
Preference >> Studio >> Android >> Click on Manage AVDs



Android Virtual Device(AVD) Manager will be opened

Here click on >> Create





A new window will be opened then fill the following fields

AVD Name: Give Any Name
Device: select any device

Target: Select the target android API

CPU/API(very important ): select  (Intel Atom x86)

Note: If you do not find (Intel Atom x86) CPU then you have to download "Intel x86 Atom System Image" for your Android SDK. Also, you have to download the “Intel x86 emulator accelerator (HAXM)” from the Extra folder. Then you have to install it. To do so, go to your Android SDK’s installation folder, then go to extras/intel/Hardware_Accelerated_Execution_Manager/ and execute IntelHAXM.dmg. 
See this link how to install the packages
- http://titaniumsolution.blogspot.com/2016/12/installing-x86-emulator-packages.html

Keyboard: if you need Hardware keyboard then check otherwise uncheck.

Skin: No Skin

Then Click on OK button.


Now you will see the emulator on the Android Virtual Device(AVD) Manager

Click on start to start it.



If you face any issue then you have to fix it otherwise it will not work.

Now run your App. Always try to start your emulator from Android Virtual Device(AVD) Manager then run App.

Localization supports for the plist file.

Suppose we are going to support for the japanese language and the camera permission. Here is the sample example.
//tiapp.xml
<ti:app>
<ios>
<plist>
<dict>
<key>NSCameraUsageDescription</key>
                   <string>Can we use your camera?</string>
</dict>
</plist>
</ios>
</ti:app>
//i18n/ja/app.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="NSCameraUsageDescription">あなたのカメラは使えますか?</string>
</resources>

Now if you change your device language to the japanese language then you will see the effect.
Hope this helps.

Fresh installation Appcelerator Studio to the windows PC.

If you download the Appcelerator Studio and try to install, it will cover all the steps automatically, but sometimes it creates problem to install. So it's better to install all other prerequisites first then install Appcelerator Studio.


If you face any issue after installation then uninstall the Studio, node.js, and all JDK, JRE version from your system then follow the following steps to install Appcelerator Studio to the Window PC.

Prerequisite and Steps
1. Install JDK8, 
2. Download compatible nodeJS version and install it
3.Then run the following command via the command prompt
- npm install -g appcelerator
- appc use latest
- appc config set proxyServer null
- appc setup
4. Finally, download the latest version of Axway Appcelerator Studio and install it on your machine. It will automatically install all other prerequisites.

Now open the Axway Appcelerator Studio.

Hope this helps.

Thursday, December 15, 2016

For the iOS 10 or later version, permission issue.

For the iOS 10 or later version, you have to add the following keys in the plist of your tiapp.xml file, if you use any one.


  • NSContactsUsageDescription: If you use the Ti.Contacts API to access contacts from the address book
  • NSCameraUsageDescription: If you use the Ti.Media.showCamera API to capture photos and videos
  •  NSCalendarsUsageDescription: If you use the Ti.Calendar API to access device calendars
  •  NSPhotoLibraryUsageDescription: If you use the Ti.Media.openPhotoGallery API to access the photo gallery or Ti.Media.showCamera API to save photos
  •  NSMicrophoneUsageDescription: If you use the Ti.Media.AudioRecorder API to record audio or Ti.Media.showCamera to record videos



<ios>
    <plist>
        <dict>
            <key>NSContactsUsageDescription</key>
            <string>Can we use to your contacts?</string>
            <key>NSCameraUsageDescription</key>
            <string>Can we use your camera?</string>
            <key>NSCalendarsUsageDescription</key>
            <string>Can we use your calendar?</string>
            <key>NSPhotoLibraryUsageDescription</key>
            <string>Can we save to your library?</string>
            <key>NSMicrophoneUsageDescription</key>
            <string>Can we use your microphone?</string>
        </dict>
    </plist>
</ios>


Thanks

Wednesday, December 14, 2016

How to transfer an App from one ORG to another.

Currently, it's not possible. You have to republish App to that ORG. And you can do it by replacing code.
Just backup and delete this project then create a new project with the same name and replace the code.
Code replacement is quite easy. Just delete the App folder to the newly created project then copy the App folder from the existing project and paste it into the newly created project. 

Note: For classic app do the same for the Resource folder.

If you use any module then include it in your app tiapp.xml file. That's it.

Thanks

Setup Android SDK to the Appcelerator Studio for windows PC

At first, download the Android SDK then place it inside the"C:" directory and show the location to the
Axway Appcelerator Studio>>Preferences>>Studio>>Platforms>Android>Android SDK Home
Then click on Install SDKs>> Now select all android 8.X.X, v7.X.X  and install those packages. 
If you face any issue then try to setup android SDK via the command prompt
  • appc ti config android.sdk  <SDK location>
  • appc ti setup android
  • And restart PC 
Also, take a look android SDK installation guide -
Hope this helps.

Push notification sample code

Appcelerator provided subscribed device token code with iOS 10 or later devices have some problem.
Actually, this portion of code is not working

Ti.Platform.name == "iPhone OS"

So please take a look this sample code for push notification

Hope this helps.

Monday, December 12, 2016

Working with commonJS module pattern.

app.js


var win = Ti.UI.createWindow({
backgroundColor : 'green',
layout : "vertical"

});

win.open();

// Create a Button.
var request = Ti.UI.createButton({
title : 'Add view',
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
top : 20,

});

request.addEventListener('click', function(e) {

var addView = require('/lib/viewFile');

var label_view = new addView();

win.add(label_view);
});

win.add(request);


// Create a Button.
var nextWindow = Ti.UI.createButton({
title : 'nextWindow',
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
top : 50

});

nextWindow.addEventListener('click', function(e) {


var nextPage = require('lib/newWin');
var Next_win = new nextPage();
Next_win.open();
//nextPage.createData();


});

win.add(nextWindow);



//ExampleView File

lib/viewFile.js


function view() {

var view = Ti.UI.createView({
width : Ti.UI.SIZE,
height : Ti.UI.SIZE,
layout : "vertical",
backgroundColor : 'red'
});

var mars = Ti.UI.createLabel({
text : 'Top 10 pics from Mars!',
top : 20,
width : Ti.UI.SIZE,
height : 30

});
view.add(mars);

view.addEventListener("click", function(e) {

var hello = require("/lib/operation");
hello.sayHello("Mars is bigger than earth");

});

// Creating label in window B, note that the same transitionName is used.
var marsB = Ti.UI.createLabel({
text : 'Top 10 pics from Mars!',

top : 20,
width : Ti.UI.SIZE,
height : 30,

});

view.add(marsB);

return view;
};
module.exports view;


/lib/operation.js


var defaultMessage = "Hello world";
// we make objects, variables, functions available to the
// calling context by adding them to the exports object
exports.sayHello = function(msg) {
alert('Hello '+msg);
};
// we can assign other objects, functions, and variables to
// exports and they will be available to the calling context
exports.helloWorld = function() {
Ti.API.info(defaultMessage);
};


/lib/newWin.js


function newWin() {

var window = Ti.UI.createWindow({
backgroundColor : 'white'
});

var textField = Ti.UI.createTextField({
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
color : '#336699',
width : 250,
height : 60
});

textField.addEventListener('click', function() {
Ti.API.info('in text field click');
});

window.add(textField);

return window;

}


module.exports = newWin;



//Project Structure










Sunday, December 4, 2016

Deploy your nodeJS app to the Heroku server in a minutes.

Just create an account to the heroku site
- https://dashboard.heroku.com/

Then download the heroku CLI and install it in your machine
- https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up

Now open the your terminal and type the following code to deploy your App

- heroku login
- heroku create YourAppName
- cd LocalPCproject/
- git init
- heroku git:remote -a YourAppName
- git add .
- git commit -am "make it better"
- git push heroku master
- heroku open

That's it.

If you change something in your app then deploy it again

- git add .
- git commit -am "make it better"
- git push heroku master

Hope this helps

Sending push via firebase API key.


 You can import a cloud enable project into Firebase. Basically similar, the end result will be a new key is generated. The steps for this are:
  • Log into Firebase console
  • https://console.firebase.google.com
  • Go to Add project >>Add Firebase to your existing project (From the Project name)
  • Select "Project Settings" from the gear menu
  • Select the "CLOUD MESSAGING" Tab and use the server key.


Note: Make sure your Appcelerator ID and package name is same











For creating new firebase project

https://documentation.onesignal.com/docs/generate-a-google-server-api-key


(Till steps 2)

Thanks.

Thursday, December 1, 2016

Appcelerator studio install on linux system

Linux systems require the GTK windowing system, Node.js, and the JDK to be installed before running Studio. So make it compatible with this link

https://platform.appcelerator.com/#/product/cli
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Then install CLI using the following command

- sudo npm install -g appcelerator
- appc use latest
- appc setup

And take a fresh copy of Appcelerator Studio and install it in your machine.

https://web.appcelerator.com/product/studio

Note: Officially Appcelerator do not have Linux support.

http://docs.appcelerator.com/platform/latest/#!/guide/Titanium_Compatibility_Matrix-section-29004837_TitaniumCompatibilityMatrix-OperatingSystem

Hope this helps.

When Studio open get an error on startup, windows platform.


Please try this following command via the terminal. 

appc logout -D
npm install -g appcelerator
appc use latest
appc config set proxyServer null
appc setup
appc login

Then open Appcelerator Studio and let us know if it works for you.