Nikola Brežnjak blog - Tackling software development with a dose of humor
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Home
Daily Thoughts
Ionic
Stack Overflow
Books
About me
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Nikola Brežnjak blog - Tackling software development with a dose of humor
Ionic, Stack Overflow

How to Launch an Ionic Web App – Where Should Ionic Server be Running?

In this StackOverflow question I answered how to launch an Ionic web app

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I answered this question by user bharat batra:

I am building an ionic app for prototyping purposes. For the first version I want it to simply be a web based app. I know how to run the app locally on my computer – I simply type ionic serve and the app runs. However, to actually have remote clients, I am not sure how to run this app. DO I need to have the ionic server running at a port on my main server, and then have the clients all make requests to that port on the server IP address? How do I actually do this?

My answer was simple:

You just take everything from your www folder and place it on your web server. That’s all there is to it.

Say your web server address is bharat.com and say you placed the www folder in your web server root. In that case, your Ionic app will be visible at bharat.com/www

How to Launch an #Ionic Web App – Where Should Ionic Server be Running? https://t.co/A6iGuaOJ9w

— Nikola Brežnjak (@HitmanHR) May 3, 2016

Ionic

How to use Exis to Create a Chat App in Ionic

This is a guest blog post from Exis where they explain how to use Exis to create a chat app in Ionic.

Exis is a BaaS startup based out of the same hometown as Ionic (Madison, Wisconsin, USA). Exis is a platform that offers developers an easy set of tools for quickly developing their application and getting it out to market easier and with less errors.

Exis provides a set of free microservices such as user login and authentication, plug and play NoSQL-based cloud storage, cloud hosting of custom Node.JS backends, and a unique take on WebSockets that offers fully authenticated bi-directional messaging both peer-to-peer and with backend components.

Exis has created and released ngRiffle, a client-side library that integrates with Ionic and has recently been teaming up with Ionic to show just how simple app development can be when you combine the two services.

Following this blog-tutorial results in creating a simple chat app using Exis + Ionic. This tutorial will showcase some of the core features that make using Exis + Ionic an excellent choice for app development including publish and subscribe messaging, and running a simple Node.js server hosted on Exis.

Step 1

Register for a free Exis account or login if you already have one.

Step 2

Create a new app named “chat”

Step 3

Add an Auth appliance

Use the options: Temporary (name, no password) for the User account type

This appliance controls who is allowed to communicate with your backend.

Step 4

Clone the Ionic App

git clone https://github.com/exis-io/ExisChatIonic.git
cd ExisChatIonic
bower install

Step 5

Link your Ionic App to the Exis App you just created

Replace USERNAME with your Exis username in xs.demo.USERNAME.chat in www/js/app.js line 43:

.config(function($riffleProvider){
$riffleProvider.SetDomain("xs.demo.USERNAME.chat");
})

Step 6

Run the Ionic App!

ionic serve

Open the app in multiple tabs and chat away!

Congrats on building a chat app using Exis + Ionic! A step by step explanation of our code is provided below.

Learn How It Works!

  1. The Code
  2. Launching A Node.js Backend

The Code

Let’s take a quick look at the main logic of the chat app which is in www/js/controller.js

angular.module('exisChat.controller', [])

.controller('HomeCtrl', function($scope, $riffle, $ionicScrollDelegate) {

    $scope.msgs = [];

    //Login anonymously to Exis (requires Auth appliance level 0)
    $riffle.login();

    //subscribe to the chat channel
    $riffle.subscribe('exisChat', gotMsg);

    //handle messages here
    function gotMsg(msg) {
        msg.received = true;
        displayMsg(msg);
    }

    //publish message
    $scope.sendMsg = function(text) {
        var msg = { username: $riffle.user.username(), msg: text }
        $riffle.publish('exisChat', msg);
        $scope.input.msg = '';
        displayMsg(msg);
    }

    //display our msg
    function displayMsg(msg) {
        $scope.msgs.push(msg);
        $ionicScrollDelegate.scrollBottom();
    }
});

That’s it! Seriously. That is what a chat app looks like with Exis + Ionic. Let’s dive in a little!

Here are the basics.

line 8: $riffle.login() anonymously logs in the user as long as there is an Auth appliance with level 0 attached to the app.

line 11: $riffle.subscribe(‘exisChat’, gotMsg) subscribes our gotMsg function to handle events publish to the exisChat channel.
gotMsg simply receives the msg marks it as a received message and displays it. You can look at the view code in www/templates/home.html

line 22: $riffle.publish(‘exisChat’, msg) publishes the message we are sending to anyone subscribed to the exisChat channel.
It’s called inside the sendMsg function which is bound to the send button in the view and it simply creates the message object, publishes it, and displays it.

line 28: displayMsg is simply a utility function used to add the msg the $scope.msgs array which is bound to the view. It also scrolls the screen down as new messages are received or sent.

And there you have it! Pretty simple right?!? There is a couple more things you can do below if you want to get a little fancy!

Launching a Node.JS Backend

Let’s take a quick look at how you could attach your own Node.js backend if you wanted. The simple backend we wrote will simply listen to messages that people are publishing and log them, but you can fork our repo and and add whatever cool imaginative logic you’d like. We’ll start with our simple logging server though.

Fork the ExisChatBackend Repo

Go to the Appliance Store and attach the Container appliance to your app.

Container

Go to Container Management

Build the image by passing in your forked repo URL of ExisChatBackend from above, name it exischat

Build Image

Create the image from the dropdown on the left, call it logger

Create Image

Start the container by pressing the Start button below.

Start Image

Now messages you send on your Exis + Ionic chat app will be logged by your backend! To verify this you can send a few messages and then go to the Logs tab on your container.
Assuming you forked our repo like we suggested you can modify the server.js code locally and push your changes to your forked repo on Github and then simply update the image to see your
changes reflected.

Thanks for following this blog-tutorial! Feel free to fork the repos and modify this app! And if you’d like to show us what you did or you have any questions feel free to email us at [email protected]

Ionic, Stack Overflow

When is it appropriate to use ion-pane in Ionic Framework?

In this StackOverflow question I answered when it is appropriate to use ion-pane in Ionic Framework

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I answered this question by user qizzacious:

This is a simple enough question.

After taking a look at the documentation for ion-pane it states:

A simple container that fits content, with no side effects. Adds the ‘pane’ class to the element.

What does it mean when it states “no side effects”? What are the use cases for ion-pane?

My answer was:

Honestly, I never used ion-pane before, but this question intrigued me so I went searching. As it seems, and you can see on this Codepen: http://codepen.io/anon/pen/JGwJKv?editors=1010, if the content is too big (if you try to resize the browser window to very small) it will not show it. Opposed to the ion-content which will add scroll bars and allow you to use ion-refresher and some other options (tapping into scroll delegate, etc.).

So, to be honest, I never stumbled upon a need for such a use-case, so would probably never use ion-pane. The lacking documentation about it, kind of suggests the same…

When is it appropriate to use ion-pane in Ionic Framework? https://t.co/3o9LVRoJxc

— Nikola Brežnjak (@HitmanHR) April 26, 2016

Ionic

60th SQL/DEV User Group meeting

Finally, I got my 5 minutes (well, OK, 45 to be exact) of fame 🙂

I was presenting Ionic Framework to  fellow developers on the 60th SQL/DEV UG meeting in Čakovec.

At this meeting there were actually two speeches:

  • Introduction to hybrid mobile app development with Ionic Framework
  • Electron

Introduction to hybrid mobile app development with Ionic Framework

  • presenter: yours truly
  • link to the presentation
  • picture time:
  • And (drums in the background) I’m very excited to announce that I’ll be speaking at the Weblica conference on 14.5.2016. Here, my name on the poster:
    thumb_IMG_6340_1024

Electron

  • presenter: Dejan Kovač
  • picture time:
    thumb_IMG_6192_1024
  • Electron website
  • Some cool apps have been built with it:
    Screenshot 2016-04-23 23.08.27
  • Electron is awesome, to be honest! We just have to wait some time so that it matures fully.
  • It’s the best time ever to be a web developer, as you now have access to every platform with the knowledge you already have

60th SQL/DEV User Group meeting #weblica https://t.co/6OVjLChKbk

— Nikola Brežnjak (@HitmanHR) April 23, 2016

Ionic

How to build a shopping app with Ionic Framework and Firebase

The sixth post about Ionic framework for Pluralsight was about making use of Firebase when building a real-time shopping TODO application.

You can see the post here: How to build a shopping app with Ionic Framework and Firebase.

You can try the app in your browser here: http://shopping-todo.com/.

You will learn how to build an app with the following features:

  • Login with Facebook or email
  • Add as many projects as you like
  • Invite as many users to your projects as you like
  • Track your expense on the go
  • View the updates live as they happen

Here are few screenshots:

In case you want to learn more about Ionic Framework, you can download (for free if you wish) my blog2book via Leanpub.

IonicBook

If you have any questions please don’t hesitate to ask, and please share if you like it.

How to build a shopping app with Ionic Framework and Firebase https://t.co/pyLYCXwWBp

— Nikola Brežnjak (@HitmanHR) April 23, 2016

Ionic, Stack Overflow

Showcasing Ionic Apps For a Portfolio Without Publishing Them to App Stores

In this StackOverflow question I answered how to showcase your Ionic apps for a portfolio without publishing them to App Stores

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I answered this question by user Jubl:

I have a few Ionic apps that I made that I want to add to my portfolio site for potential employers to check out. However, I would like to upload them somewhere so that when a visitor clicks on my link, it will take them to a website showcasing my app. I don’t want to push my apps to the actual stores, but still make them publicly viewable. Is this possible to do with an Ionic application?

I understand that Ionic View exists, but I have to send out email permissions for people to try my app (from what I know). I’d rather my apps just be uploaded somewhere and be easily accessible through links.

My answer was:

Actually, with Ionic View you can just share its ID number (see the image below) and anyone with this number will be able to download your app (via Ionic View) without you having to send them the invitation.

Your second option, but maybe a bit harder to do is to host your application on your server. So, you would take all the content from the www folder and simply put it on your server in a certain folder and your app would then be accessible from the web as well. What I usually do is I create an iPhone image and create an iframe in which I then show the Ionic app. I won’t go into details here, there are similar questions that cover this particular topic already.

Anyways, hope this helps, and clearly for the least effort, the Ionic View seems like the best option.

#Showcasing #Ionic Apps For a Portfolio Without Publishing Them to App Stores https://t.co/3npCjin5rG

— Nikola Brežnjak (@HitmanHR) April 23, 2016

Ionic

Ionic Framework: A definitive 10,000 word guide

The fifth post about Ionic framework for Pluralsight is actually a condensed (well, if you can call a 10,000+ word article condensed ;)) article of the series so far.

As you may remember, the series wraps everything in a whole where we showed how to create an application starting with an idea, through creating a prototype and implementing the application using Ionic framework to finally publishing it in the stores.

You can see the post here: Ionic Framework: A definitive 10,000 word guide.

The original tutorials (totaling 20k+ words) are not available anymore, but you can still access (for free if you wish) my blog2book which has them in their original form via Leanpub.

IonicBook

If you have any questions please don’t hesitate to ask, and please share if you like it.

Ionic Framework: A definitive 10,000 word guide https://t.co/ZTNjt1YfwZ

— Nikola Brežnjak (@HitmanHR) April 23, 2016

Ionic, Stack Overflow

Cordova and Ionic SMS Receiver

In this StackOverflow question I answered why it isn’t possible to read SMS in Ionic application which you want to deploy to Apple’s App Store

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I answered this question by user aintno12u:

Good day, do you have any idea how to achieve this in ionic? I found tutorials for PhoneGap but that was 3 years ago and i dont know if it will work with my ionic app. The ng-cordova has only thishttp://ngcordova.com/docs/plugins/sms/ to send sms but not receive. I saw this also but i have no idea how to use it. https://github.com/floatinghotpot/cordova-plugin-sms/tree/master/docs. Please help. Ionic so new that it lacks tutorials.

My answer was:

In case you’re trying to get this kind of application to the App Store, I have bad news for you.

As this answer states:

Simply two words from Apple: Not Possible

Cordova and Ionic #SMS Receiver https://t.co/jk58Gx4P0M

— Nikola Brežnjak (@HitmanHR) February 16, 2016

Ionic, Stack Overflow

Why doesn’t window.something throw an error?

In this StackOverflow question I asked why doesn’t window.something throw an error

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I actually asked this question myself:

I’m using an AdMob plugin in my Ionic application, and one way, as you can see in the documentation, to test if the plugin is properly loaded is to do:

if(AdMob) {
    ///other config code...
}

Now, this works perfectly fine on a device. However, it doesn’t work in the browser; it throws an error in the console log: AdMob is not defined.

I have found a solution to test the existence of plugin like this (without throwing an error in the console):

if (window.AdMob){...}

And I have seen this usage on multiple questions here on StackOverflow. However, I wasn’t able to find an explanation to as why this doesn’t throw an error.

I have a vague reasoning to as why this would be so, but I would really appreciate it if someone experienced could explain it in more detail.

edit: I made additional tests like this:

var a = "hi";
console.log(a); //shows "hi"
console.log(b); //throws an error that b is not defined

var c = {};
c.b = "hi again";
console.log(c.b); //shows "hi again" as expected

//and now for the grand finale
console.log(c.something);//doesn't throw an error, please explain to me in more detail why?

The answer by T.J. Crowder was:

I wasn’t able to find an explanation to as why this doesn’t throw an error.

In the first example, you’re trying to read the value of a completely undefined identifier. In the second example, you’re trying to read a property from an object that the object may not have.

Trying to read the value of an undefined identifier is a ReferenceError; the JavaScript engine has no idea what that identifer is. In contrast, trying to read the value of a property that the object doesn’t have yields the value undefined.

It’s just how the language is designed, where Brendan Eich drew the line: It’s okay to read the value of a non-existant property from an object, but not okay to read the value of an undeclared identifier.

I should point out a third option: typeof. You’re allowed to provide an undefined identifier as the operand to typeof:

if (typeof AdMob === "undefined")

That won’t throw a ReferenceError even if AdMob is undeclared; instead, typeof will yield "undefined". (It will also yield "undefined' if AdMob is a declared identifier with the value undefined in it.)

In a comment on another answer, you said:

…it would just indeed help to see the exact official specification which confirms this.

That would be the ECMAScript specification, specifically §6.2.3.1 for throwing a ReferenceError on an unresolvable symbol, and §9.1.8 for returning undefined for a property that doesn’t exist. But I should warnin you that the spec, especially this 6th edition spec, is very heavy going. 🙂

Why doesn’t #window.something throw an #error in @ionicframework? #javascript https://t.co/e0vMYiHJAU pic.twitter.com/lPHcStpDA5

— Nikola Brežnjak (@HitmanHR) February 11, 2016

Ionic, Stack Overflow

What do Yeoman Generators “really” add to Ionic Projects?

In this StackOverflow question I answered what do actually Yeoman Generators add to the Ionic projects.

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

As you may know, I’m really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I’m currently #3 in the top All time answerers list.

I answered this question by user qizzacious:

I don’t understand why the generator-ionic (along with other ionic + Yeoman project)s are so popular.

I don’t see what the advantages are in using a yeomen generator in this case, this is.

I understand why the Ionic framework is useful in a Cordova project (as we all know, the UI, ngCordova plugins, it uses AngularJS, ect) but what specifically does the Yeoman component add that a basic Ionic project doesn’t already have or that cannot be easily added with a bower install.

It seems to me that the Yeoman ionic projects just seem to be unnecessary bloat and can lead to more errors and library issues. I just do not see how components like karma and grunt (as opposed to ionic using gulp) fit into help with development.

My answer was:

True, you can set all this up by yourself. However, imagine setting this up on each and every project that you start. Kind of cumbersome, don’t you think?

That’s why some people tend to create these generators – to save you (if you like) the time of having to scaffold your application every time from beginning. Usually they provide some features (about which you can read on the Github pages) or they may even enforce some kind of project directory layout (which may help with big projects).

All in all, you don’t have to use them, or stress about them. For instance, I personally don’t use them on every project, but I appreciate the community effort and when I want to try something quick I tend to test them from time to time to see how they’ve evolved.

Don’t hate, donate 😉 (Sure sure, I know you’re not hating, the statement just seemed appropriate).

What do #Yeoman #Generators "really" add to #Ionic Projects? @ionicframework https://t.co/GIbcndBiIQ

— Nikola Brežnjak (@HitmanHR) February 2, 2016

Page 2 of 7«1234»...Last »

Recent posts

  • Discipline is also a talent
  • Play for the fun of it
  • The importance of failing
  • A fresh start
  • Perseverance

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (35)
  • Daily Thoughts (77)
  • Go (3)
  • iOS (5)
  • JavaScript (127)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (2)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (77)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (40)
  • Servers (8)
    • Heroku (1)
    • Linux (3)
  • Stack Overflow (81)
  • Unity3D (9)
  • Windows (8)
    • C# (2)
    • WPF (3)
  • Wordpress (2)

"There's no short-term solution for a long-term result." ~ Greg Plitt

"Everything around you that you call life was made up by people that were no smarter than you." ~ S. Jobs

"Hard work beats talent when talent doesn't work hard." ~ Tim Notke

© since 2016 - Nikola Brežnjak