All rights are reserved by Niteesh Kumar.. Theme images by Storman. Powered by Blogger.


Total Pageviews

Blog Archive

Follow by Email


Featured Posts

Saturday, 18 April 2020

OAM authentication not wroking in react native iOS (Unable to open URL in iOS)

- No comments
If you  using "react-native-webview": "^9.1.0" in your application and trying to implement OAM authentication in your react native application it will show error saying Unable to open URL in iOS. 

The problem is with react-native-webview version. I was facing the same problem and resolved the unable to open URL issue in iOS by downgrading the react-native-webview version to 8.0.6.

"react-native-webview": "8.0.6",

Monday, 13 January 2020

spawnsync ./gradlew eacces react native

- No comments
This is a permission issue mostly occurs while running on macOS.

You can resole this error -  spawnsync ./gradlew eacces react native by giving permission to the gradlew directory-

Go to the project directory and run below command-

chmod 755 android/gradlew

Tuesday, 13 August 2019

React Native Orientation not working iOS


While developing React Native Mobile Applications we often face challenges regarding device orientation. Common issues that we face are - 

  1. Get device Orientation
  2. Lock application to portrait mode 
  3. Lock application to landscape 
  4. Lock application to portrait mode and enable landscape mode for some screens only

for all those requirements listed above, we use the react-native-orientation library.

To setup the library follow the steps given in the documentation of react-native-orientation. follow the URL given below-

While setting up the library keep this thing in mind that in case of iOS linking the documentation says that you have to add following lines in AppDeligate.m file - 

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { while ([[UIDevice currentDevice] isGeneratingDeviceOrientationNotifications]) {< [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; } return [Orientation getOrientation];

What I have noticed is that after making this change we will see some issues in iOS. Such that - 
  1. OrientaionListener is not working after lockToPortrait() or lockToLandscape() or UnlockAllOrientation()
  2. lockToPortrait() or lockToLandscape() or UnlockAllOrientation() are not working
  3. The device is not coming back to portrait mode after switching to landscape mode
  4. The device is not coming back to landscape mode after switching to portrait mode
To fix all those issues we need to make the below change. Instead of adding the lines sown above you only have to add the lines below-

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return [Orientation getOrientation];

Because while loop in this creating problem and because of this some times orientation listeners are not getting triggered. 

Wednesday, 8 May 2019

React Native Push Notification Android & iOS


Today We are going to discuss How to set up React Native Push Notification with react native for both Android and iOS. There are multiple packages available to implement the same. for example-

  1. react-native-firebase
  2. react-native-push-notification
  3. react-native-fcm
I have tried all three packages mentioned above. But today I am going to discuss react-native-push-notification as after trying all three of them I found this on more convenient to use.

First We will discuss how to setup react-native-push-notification for Android & iOS in your react native project.


Step by Step Guide to Set Up React Native Push Notification-  

1 - First of all, install react native push notification package in your react native project. Use the command given below -

npm install --save react-native-push-notification For iOS you can also use - yarn add react-native-push-notification

2 - If you will go through react native push notification official documentation you will see react-native link react-native-push-notification. But this will not link the package completely and you may face some problem. So it's we should link manually.

React Native Push Notification Android Manual Linking -

1 - Go at android/app/build.gradle and add the following dependencies - 

dependencies { ...... implementation project(':react-native-push-notification') implementation ('') ...... }

You can use a specific gcm-play-service version and change the version number 8.1.0 for your version. In some cases, you may see an error like gcm-play-service version is 16.1.0 at run time but it is getting 8.1.0 at compile time.
So, in that case, change the version number from 8.1.0 to 16.1.0.

2 -  Now go to your android/app/src/AndroidMenifest.xml file and add the following changes - 

Just below uses-permission add the following lines -

<uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

and just before closing application tag add the lines given below-

<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" android:value="YOUR NOTIFICATION CHANNEL NAME"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description" android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@android:color/white"/> <receiver android:name="" android:exported="true" android:permission="" > <intent-filter> <action android:name="" /> <category android:name="${applicationId}" /> </intent-filter> </receiver> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerServiceGcm" android:exported="false" > <intent-filter> <action android:name="" /> </intent-filter> </service> <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false" > <intent-filter> <action android:name="" /> </intent-filter> </service>

NOTE -  Replace ${applicationId} with the application ID that you are using in firebase application. As your application id should be same both in the firebase application that you have created for the push notification and the project you are working in. 

Go to your android/app/build.gradle file and you will find applicationId in defaultconfig

3 - Now go to your file inside android/src/main/java... and do the following steps - 

Add the line below in the imports of your  -

import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;

Add the following line inside the implementation of MainApplication - 

@Override protected List<ReactPackage> getPackages() { return Arrays.<reactpackage>asList( new MainReactPackage(), new ReactNativePushNotificationPackage(), //Add This Line

4 -  Go to your settings.gradle file and add the following line on the bottom of the file - 

include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')

Now you are done with linking react-native-push-notification package for Android.

React Native Push Notification iOS Manual Linking -

For iOS, we will be using PushNotificationIOS library that is provided by react-native itself. To use this you need to link the PushNotificationIOS library from X-Code to your project. Follow the URL given below to manually link this library with your react native project-

After Successfully linking this library follow the steps given below for further set up of iOS push notification set up -
1 - To enable the support for push notification and register event you need to make some changes in your AppDeligate.

Add the below line on the top of your Appdelegate.m file -  

#import <React/RCTPushNotificationManager.h>
2 - After this add the blow lines in your AppDelegate Implementation just above @end

// Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings]; } // Required for the register event. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } // Required for the notification event. You must call the completion //handler after handling the remote notification. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } // Required for the registrationError event. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error]; } // Required for the localNotification event. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [RCTPushNotificationManager didReceiveLocalNotification:notification]; }

Now for iOS we are done setting up react native push notification.

Wednesday, 1 May 2019

Composite Transformation

- No comments

What is Composite Transformation?

When we are performing two or more transformations in a geometric figure to create a new figure or shape, we call it a composite transformation.

In the code given below, you will get a choice that which transformation you want to perform in the given figure among Translation, Rotation, and Scaling.

#include bits/stdc++.h ;
#include graphics.h; using namespace std; int gd,gm; //function for rotation void rotation(int side[][3],int n) { int theta,res[100][100]; printf("Enter the rotation angle:"); scanf("%d",&theta); int mat[3][3]={{cos(theta),sin(theta),0},{-sin(theta),cos(theta),0},{0,0,1}}; detectgraph(&gd,&gm); initgraph(&gd,&gm,""); for(int i=0;i<n-1;i++) line(side[i][0],side[i][1],side[i+1][0],side[i+1][1]);\ line(side[n-1][0],side[n-1][1],side[0][0],side[0][1]); for(int i=0;i<n;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) res[i][j]+=side[i][k]*mat[k][j]; for(int i=0;i<n-1;i++) line(res[i][0],res[i][1],res[i+1][0],res[i+1][1]); line(res[n-1][0],res[n-1][1],res[0][0],res[0][1]); getch(); } //function for scaling void scaling(int side[][3],int n) { int sx,sy,res[100][100]; printf("Enter the scaling co-ordinates:"); scanf("%d%d",&sx,&sy); int mat[3][3]={{sx,0,0},{0,sy,0},{0,0,1}}; detectgraph(&gd,&gm); initgraph(&gd,&gm,""); for(int i=0;i<n-1;i++) line(side[i][0],side[i][1],side[i+1][0],side[i+1][1]); line(side[n-1][0],side[n-1][1],side[0][0],side[0][1]); for(int i=0;i<n;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) res[i][j]+=side[i][k]*mat[k][j]; for(int i=0;i<n-1;i++) line(res[i][0],res[i][1],res[i+1][0],res[i+1][1]); line(res[n-1][0],res[n-1][1],res[0][0],res[0][1]); getch(); } //function for translation void translation(int side[][3],int n) { int tx,ty,res[100][100]; printf("Enter the translation co-ordinates:"); scanf("%d%d",&tx,&ty); int mat[3][3]={{1,0,0},{0,1,0},{tx,ty,1}}; detectgraph(&gd,&gm); initgraph(&gd,&gm,""); for(int i=0;i<n-1;i++) line(side[i][0],side[i][1],side[i+1][0],side[i+1][1]); line(side[n-1][0],side[n-1][1],side[0][0],side[0][1]); for(int i=0;i<n;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) res[i][j]+=side[i][k]*mat[k][j]; for(int i=0;i<n-1;i++) line(res[i][0],res[i][1],res[i+1][0],res[i+1][1]); line(res[n-1][0],res[n-1][1],res[0][0],res[0][1]); getch(); }
//driver program
int main()
{ int n,ch; printf("Enter number of sides:"); scanf("%d",&n); int side[n][3]; for(int i=0;i<n;i++) scanf("%d%d%d",&side[i][0],&side[i][1],&side[i][2]); printf("1-Translation\n2-Rotation\n3-Scaling\nEnter your choice:"); scanf("%d",&ch); switch(ch) { case 1: translation(side,n); break; case 2: rotation(side,n); break; case 3: scaling(side,n); break; default: printf("Wrong choice!!"); break; } return 0;

Tuesday, 30 April 2019

How to take backup of all your BlogSpot posts


Blogger is the second most popular free blogging platform after WordPress. Blogger is own by Google and it has all the rights. Blogger is easy to set up compared to WordPress as it has fewer features and simple navigation. Most of the people who do full-time blogging prefer WordPress. 

Suppose you have started your blog in Blogger and now you want to shift to WordPress for some reasons and also want to move all your Blogger content to your new WordPress Website then I have got good news for you.

For all the bloggers who are thinking to move from blogger to WordPress, the main concern is how they can reuse the existing content of their website? or how to take the backup of all the blogger content?

I will explain here the step wise step process to take the backup of all your blogger posts. It's a simple three step process.

To backup blogger Content - 

  • Log in to your Blogger Dashboard
  • go to settings > other page 
  • Under import & Backup section click on the Backup content
How to take backup Blogger posts

  •  It will open up a popup saying Save To Computer 

  • Click on that save to computer button.
  • Save that .xml file in your computer which contains all the content you have ever posted in your blogger blog.

Sunday, 4 November 2018

Top 7 must have WordPress plugins for any WordPress website

In this article, we will talk about the top 7 must have WordPress plugins for any WordPress website. You should try all these WordPress plugins as they will really benefit your business, grow your audience and drive more traffic to your website.

Follow along with me step by step as I will take you through each WordPress plugin explaining how each of them works and what benefits you will start to see.

You can easily use all the plugins as each plugin is absolutely free.

1: SEO Friendly Images 
This little WordPress plugin basically improves traffic from search engine. which is exactly what we want. SEO friendly images plugin automatically updates ALT and Title attribute of all your images for SEO purpose.

The ALT attribute is an important part of SEO as it describes your images to search engines. So, when we search any image this is a key determining factor for a match. The title also plays an important role as it provides information about the image when we hover the mouse above image. 

This is a simple WordPress plugin but extremely effective in getting your images to show up in search results and driving even more traffic to your website.

2: WP Socializer
It is a supercool WordPress plugin which inserts social bookmarking, sharing buttons as well as floating widgets. You can insert these buttons on the posts & sidebars so the people visiting your website can easily like and share your content on social media. There are a lot of social bookmarking plugins available which can be used in many possible ways.

3: Contact form 7
This Wordpress plugin enables you to add a contact form on your website & this is super easy to use. All you need to do is install and edit either existing contact form or create a new one from scratch. 
For any business, it is more important to have ways to generate leads. You can add contact form as a lead magnet. Having a lead magnet is incredibly important for the success of any business.

4: Yoast SEO WordPress Plugin
This is a complete WordPress SEO plugin that exists today. It incorporates everything from google snippet preview and page analysis functionality, which helps optimize your page content, image, title, meta description and a lot more.

There are also a lot of optimizations methods available in between. Yoast SEO also let you set templates for titles and meta description. So, you can come up with a template and don't have to think about these things. 

Snippet preview let you see how it will look like in google search.

5: Sumo me
 This is list builder WordPress Plugin and list builder converts a one-time visitor to lifelong readers. It is like exit intent in your website as whenever user will leave it will pop up immediately asking for visitors email address. 

It is completely customizable and free. This can be a game changer for your business if used properly.

6: Google XML Sitemaps
This WordPress plugin might look confusing. This plugin generates XML sitemaps which means it helps search engines like google to index your website much better and for the information in your website to retrieve more efficiently. Which results in much more traffic and high ranking in search results. Who doesn't want that and well this plugin does exactly the same.

7: Yoast Google Analytics:
This WordPress plugin starts tracking your visitors, who are they, where are they from, what are they doing on your website and what are they actually using to visit your website. Having this WordPress plugin allows you to know your audience because no two people think exactly the same. Having google analytics WordPress plugin helps you analyze visitor traffic and paint a complete picture of your audience. You can see what people are visiting your site up to. 

You can see the visual analysis of visitors for your pages like what they are visiting and what they like and then tailor your marketing strategies. Knowing all this helps you serve your current customer better as well as the new customer. 

Tuesday, 10 July 2018

learn sending emails in python

- No comments
If you are a working professional and your job is to send a lot of emails to the client or customers on daily basis. Then this will be a very hectic task for you as compose mail for each person in the list.

Python includes several modules in the standard library for working with emails and email servers. As a learning exercise, I recently worked with Python 3 to see how I could use python for sending emails using smtp servers. Here I am writing a tutorial for the same.

Before starting there are few prerequisites you must have -
  •  You must have python installed in your system.

  • Working Internet

Python has various libraries to work with emails. We will use smtplib.

SMTP stands for Simple Mail Transfer Protocol.
smtplib module defines an SMTP client session object and we will use this object to send emails in python to any internet machine with SMTP or ESMTP listener.

Sending emails in python is done using smtplib module using SMTP server.

Actual usage varies depending upon the complexity of email as for detailed emails we also need to use email module. The tutorial given below is for sending emails in python through Gmail.

Basic Script to send emails in Python:

First of all, you need to create an SMTP object and each object you create will be used for connection with one server

import smtplib
server = smtplib.SMTP('', 587)

Next, we need to login to the server - 

server.login("youremailusername", "password")

And now send the email - 

msg = "\nHello!" # The /n separates the message from the headers (which we ignore for this example)
server.sendmail("", "", msg)

The script written above is very basic without header, subject etc. We will use email module to make it more advanced.

email module overview:
Python's email package contains many classes and functions for composing and parsing email messages. We will cover only a small section that is used to send emails.

Use of email package:
We can directly import email module but if we do this we need to write full module name. So we only import classes that are needed.

from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

After importing the required classes we will compose some of the basic headers.

fromaddr = ""
toaddr = ""
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "Python email"

now we will attach the body of the message to MIME(multipurpose internal mail extension) message.

body = "sending test emails using python"
msg.attach(MIMEText(body, 'plain'))

for sending the email we need to convert the message to string and then use the same procedure as above to send email using the SMTP server.

import smtplib
server = smtplib.SMTP('', 587)
server.login("youremailusername", "password")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)

Writing a function to send emails using Gmail in Python:
We will write a function which can return a dictionary of any addresses it could not forward to and other connetion problems raise errors.

import smtplib
def sendemail(from_addr, to_addr_list, cc_addr_list,
              subject, message,
              login, password,
    header  = 'From: %s\n' % from_addr
    header += 'To: %s\n' % ','.join(to_addr_list)
    header += 'Cc: %s\n' % ','.join(cc_addr_list)
    header += 'Subject: %s\n\n' % subject
    message = header + message
    server = smtplib.SMTP(smtpserver)
    problems = server.sendmail(from_addr, to_addr_list, message)
    return problems

Call the above function to send emails:

sendemail(from_addr    = '', 
          to_addr_list = [''],
          cc_addr_list = [''], 
          subject      = 'Howdy', 
          message      = 'Howdy from a python function', 
          login        = 'pythonuser', 
          password     = 'XXXXX')

Monday, 9 July 2018

How to create your own chatbot in Python

In this article, you will see that how you can create your own chatbot in Python language. Before getting started to coding part let me give you a quick introduction to what is a chatbot and why it is so relevant in business.

What is a Chatbot?
A chatbot os computer program that mimics human conversation in the international format using AI technique such as natural language processing.

If you see in today's business world chatbot is the major talking point why it is so relevant in business. We are living in an era where customers are more proficient in using modern technologies and they are always connected to social platforms through their Smart mobile devices. So the arrival of chatbots has opened up a new scope in customer engagement. This new generation of customers always expects the real-time response to their queries and also they demand more personalized suggestion from the brand.

So in order to satisfy these kinds of customer demands and to address the increasing competition in the business space businesses are now focusing on building a chatbot that can manage customer queries round the clock without any delay.

In this tutorial, we will use a Python Package called chatterbot. So you have to install this package chatterbot first. To install chatterbot type the command in terminal or command prompt given below-

pip install chatterbot
and press enter. We are also going to use chatterbot corpus for this chatbot. You can download this from GitHub. 

Download chatterbot corpus here.

Download Zip file from above link and extract it in the same folder where you are going to create your chatbot file. You will see inside chatterbot-corpus folder there will be a directory named data and inside this, you will see multiple directories naming multiple languages. Inside these directories, we have data of conversation which we will use to train our chatbot.

Let's start the coding part. Follow step by step to create your own chatbot in Python-

IMPORTANT NOTE: Please write your own code instead of copying the code from here because you may face indentation problem in copying.

1- first of all we need to import chatter bot packages

from chatterbot import ChatBot 
from chatterbot.trainers import ListTrainer
import os 

2 - Next we need to define our bot. You can name it any name you want to. I am going to name it simply as a bot and next I need to set my trainer to train my bot.

bot = ChatBot('Bot') 

3 - Next we need to load chatterbot corpus files that we have already downloaded in our local system. Copy the path of English data files and next, we need to open data so we will use the same part to open data with concatenated files iterator so that we will have the entire path to our files.

and after that, we need to train out bot using bot.train() with the data we have loaded into the script-

path = 'C:/Users/Niteesh Kumar/Desktop/chatbot/chatterbot-corpus-master/chatterbot_corpus/data/english/'  
for files in os.listdir(path):
    data = open(path + files, 'r').readlines()

4 - When the training is completed we need to get the inputs from the user by using input function and labeling it as you. 
Next the reply will be generated from thebot using bot.getresponse() function of the message which the user enters.

Next, we need to print the reply from chatbot.

To end this conversation we will create a condition when the message entered by the user is equal to bye then beak the conversation by printing bye.

 we will also create an if condition before chatbot reply. That it only start the conversation if the user's message is not bye.

while True:
    message = input('You:')
    if message.strip() != 'Bye':
        reply = bot.get_response(message)
        print('ChatBot :', reply)
    if message.strip() == 'Bye':    
        print('ChatBot : Bye')

save the complete code in a file and execute it. you will see that list trainer that we have set to train our bot is now training the bot using the data which have used in the script. 

chatbot in python

You can also create your own corpus like a collection of files which has a conversation, which has a dialogue in different topics and use that dialogue to train your chatbot.

Below is the conversation with the chatbot I have created-

chatbot in python conversation

Download the complete code here

You will see that each time you execute this file it get trained first. But this is only needed when you have a new set of data. But you have fixed set of data so you only need to train once.

Go to the directory where you have saved this file and you will see that there is also another file named db.sqlite3  which contain all the training you have done. 

So instead of training, again and again, train only once. To do this run the above file only once and create a new file and write lines given below - 

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os
bot = ChatBot('Bot')
while True:
if message.strip() != 'Bye':
print('ChatBot:', reply)
if message.strip() == 'Bye':
print('ChatBot : Bye')


save this file in the same directory and run this and you will see that chatbot is working without training. See it here - 

basic chatbot in Python

You can see that chatbt has started working withot training.

If you are facing any problems. Please feel free to comment below.