Sunday, May 26, 2024

Regular Expression

 regEx

Quantifiers

Metacharacters

Groups

flags


/abdul/A regular expression
/abdul/iA case-insensitive regular expression
/gPerform a global match (find all)
/iPerform case-insensitive matching
/mPerform multiline matching

var pattern = /abdul/

text.match(pattern)


---------------------------------------------------------------------

let text = "aaaabb"; 

let result = text.match(/(aa)(bb)/d);


---------------------------------------------------------------------------

let text = `Is this

all there

is`


let pattern = /^is/m;

let result = text.match(pattern);


-------------------------------------------------------------------------


The "m" modifier specifies a multiline match.

It only affects the behavior of start ^ and end $.

^ specifies a match at the start of a string.

$ specifies a match at the end of a string.

With the "m" set, ^ and $ also match at the beginning and end of each line.



<p>Do a global, case-insensitive, multiline search for "is" at the beginning of each line in a string.</p>

let text = `Is this

all there

is`


let pattern = /^is/gmi;


-------------------------------------------------------------------------------------------------


<p>The multiline property returns true if the "m" modifier is set, otherwise false:</p>


<p id="demo"></p>


<script>

let text = "Visit W3Schools!";

let pattern = /W3S/gmi;

let result = pattern.multiline;


-------------------------------------------------------------------------------------------------


Regular Expression Search Methods

text.match(pattern)The String method match()
text.search(pattern)The String method search()
pattern.exec(text)The RexExp method exec()
pattern.test(text)The RegExp method test()

search() searches a string for a value and returns the position of the first match

match() searches for a match in a string

The test() method returns true if it finds a match, otherwise false.

The exec() method tests for a match in a string

Thursday, April 4, 2024

Abdulkareemjavascript

  1.Using arrow function:

const first = ()=>{

const greet='Hi';

const second = ()=>{

const name='john';

console.error(greet);

}

return second;


}

const newFunc =first();


Notes:

here do call the function of first have to assign const variable and call that as variable name (Example:newFunc();)


2.Closures

Example:


function createGreeter(greeting) {

  return function(name) {

    alert(greeting + ', ' + name);

  }

}

const sayHello = createGreeter('Hello');

output:

sayHello('Joe');

// Hello, Joe


example2:

<!DOCTYPE html>

<html>

<body>


<h2>JavaScript Closures</h2>


<p>Counting with a local variable.</p>


<button type="button" onclick="myFunction()">Count!</button>


<p id="demo">0</p>


<script>

const add = (function () {

  let counter = 0;

  return function () {counter += 1; return counter;}

})();


function myFunction(){

  document.getElementById("demo").innerHTML = add();

}

</script>


</body>

</html>

The variable add is assigned to the return value of a self-invoking function.

The self-invoking function only runs once. It sets the counter to zero (0), and returns a function expression.

This way add becomes a function. The "wonderful" part is that it can access the counter in the parent scope.

This is called a JavaScript closure. It makes it possible for a function to have "private" variables.

The counter is protected by the scope of the anonymous function, and can only be changed using the add function.

3.

If you want to extract properties under a different name, you can specify them using the following format

const obj = {

  name: 'Joe',

  food: 'cake'

}

const { name: myName, food: myFood } = obj;

console.error(myName, myFood);

output:

Joe cake


const obj = {

  name: 'Joe',

  food: 'cake'

}

const { food: myName,name: myFood } = obj;

alert(myName, myFood,obj);

output:

cake Joe {name: 'Joe', food: 'cake'}



4.

In the following example, destructuring is used to cleanly pass the person object to the introduce function. In other words, destructuring can be (and often is) used directly for extracting parameters passed to a function. If you’re familiar with React, you probably have seen this before!

const person = {


  name: 'Eddie',


  age: 24


}

function introduce({ name, age }) {


  console.log(`I'm ${name} and I'm ${age} years old!`);


}

introduce(person);

5.


const oldarr = [4, 6, -1, 3, 10, 4];


const newarr = new Set(oldarr);


alert(newarr);

alert(oldarr);

const arr1 = [4, 6, -1, 3, 10, 4];


const max = Math.max(...arr1);


alert(max);

output:

Set(5) { 4, 6, -1, 3, 10 }

[ 4, 6, -1, 3, 10, 4 ]

10


Array Methods

1.Map Methods

const arr = [1, 2, 3, 4, 5, 6];

const mapped = arr.map(el => el + 20);

console.log(mapped);

// [21, 22, 23, 24, 25, 26]


2.Filter Methods



const arr = [1, 2, 3, 4, 5, 6];

const filtered = arr.filter(el => el === 2 || el === 4);

console.log(filtered);

// [2, 4]


3.Reduce Methods


const arr = [1, 2, 3, 4, 5, 6];

const reduced = arr.reduce((total, current) => total + current);

console.log(reduced);

// 21


4. Find Methods


const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const found = arr.find(el => el > 5);

console.log(found);

// 6


note that while everything after 5 meets the criteria, only the first matching element is returned.


This is actually super helpful in situations where you would normally break a for loop when you find a match!



5.findIndex


const arr = ['Nick', 'Frank', 'Joe', 'Frank'];

const foundIndex = arr.findIndex(el => el === 'Frank');


console.log(foundIndex);

// 1


6.indexOf


const arr = ['Nick', 'Frank', 'Joe', 'Frank'];

const foundIndex = arr.indexOf('Frank');


console.log(foundIndex);

// 1



push, pop, shift, unshift


7.push()


push() adds new items to the end of an array:

let arr = [1, 2, 3, 4];

const pushed = arr.push(5);


console.log(arr);

// [1, 2, 3, 4, 5]

console.log(pushed);

// 5



8.

unshift() 

adds new items to the beginning of an array:

const fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.unshift("Lemon", "Pineapple");


document.getElementById("demo").innerHTML = fruits;



output:

Lemon,Pineapple,Banana,Orange,Apple,Mango



9.shift()

 removes the first item of an array:

const fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.shift();


document.getElementById("demo").innerHTML = fruits;


output:

Orange,Apple,Mango



10. pop()

 removes the last element of an array

const fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.pop();

document.getElementById("demo").innerHTML = fruits;


output:


Banana,Orange,Apple

https://hackernoon.com/12-javascript-concepts-that-will-level-up-your-development-skills-b37d16ad7104


11.Remember self-invoking functions(closure function)


closure function

The variable add is assigned to the return value of a self-invoking function.

The self-invoking function only runs once. It sets the counter to zero (0), and returns a function expression.

This way add becomes a function. The "wonderful" part is that it can access the counter in the parent scope.

This is called a JavaScript closure. It makes it possible for a function to have "private" variables.

The counter is protected by the scope of the anonymous function, and can only be changed using the add function.

const add = (function () {
  let counter = 0;
  return function () {counter += 1; return counter}
})();

add();
add();
add();

// the counter is now 3

14.anonymous function

 function(){

//body

}

(()=>{

//body

})();



Call is a function that helps you change the context of the invoking function. In layperson's terms, it helps you replace the value of this inside a function with whatever value you want.

Apply is very similar to the call function. The only difference is that in apply you can pass an array as an argument list.

Bind is a function that helps you create another function that you can execute later with the new context of this that is provided.

Wednesday, October 20, 2021

Dynamic data in segment and filter

 define({ 


  //Type your controller code here 

  onNavigate:function(){

    this.view.btnSearch.onClick =this.Dynseg;

    this.view.txtsearch.onTextChange =this.ontxtDynseg;

    this.view.txtsearch.text="";

    this.Dynseg();

  },

  ontxtDynseg:function(){

    if(this.view.txtsearch.text.trim().length === 0)

    {

      this.Dynseg();    

    }

  },

  Dynseg:function(){

    var data = [

      {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "zenny thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "benny thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "venny thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "",

        "imgRightArrow": "calright.png",

        "lblAcountName": "benny thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "benny thomas",

        "lblBeneficiaryName": "benny"

      },{

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "Ana thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "Honey thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "Enna thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "steve.png",

        "imgRightArrow": "calright.png",

        "lblAcountName": "benny thomas",

        "lblBeneficiaryName": "benny"

      }, {

        "imgProfile": "",

        "imgRightArrow": "calright.png",

        "lblAcountName": "Welcome thomas",

        "lblBeneficiaryName": "benny"

      }

    ];

    var arr3 =[];

    arr3 = data;

    //     var length = arr3.length;

    var sData = [];


    for (var ii = 0; ii < arr3.length; ii++) {


      if (arr3[ii].lblAcountName !== null || arr3[ii].lblAcountName !== undefined) {


        var txt1 = "";

        if (arr3[ii].lblAcountName !== null && arr3[ii].lblAcountName !== undefined) {


          txt1 = arr3[ii].lblAcountName;


        }

        var pattern = this.view.txtsearch.text.trim().toUpperCase();


        if (txt1.toUpperCase().search(pattern) !== -1) {

          sData.push(arr3[ii]);

        }

      }

    }

    if(sData.length > 0){

      const transformed = {

        data:[]

      };


      const findByLetter = (letter) => (element) => element.letter === letter; 

      for(let i = 0; i < sData.length; i++){


        const letter = sData[i].lblAcountName.split("")[0];

        const elIndex = transformed.data.findIndex(findByLetter(letter));

        if(elIndex > -1){

          transformed.data[elIndex].idata.push(data[i]);

        }else{

          transformed.data.push({

            letter,

            idata: [sData[i]],

          });

        }


      }


      transformed.data=transformed.data.sort((a, b) => a.letter.localeCompare(b.letter));

      // const newArray= transformed.data.map(element=>[element.letter,element.idata]);

      const newArray= transformed.data.map(element=>[{"flxsecHdrTemp":{skin:"sknflxSecHdrbg463faf"},"letter":{isVisible:true,text:element.letter}},element.idata]);  

      this.view.segLst.removeAll();

      this.view.segLst.setData(newArray);

      this.view.segLst.setVisibility(true);

      this.view.lblnodatafnd.isVisible=false;

    }else{

      this.view.segLst.removeAll();

      this.view.segLst.setVisibility(false);

      this.view.lblnodatafnd.isVisible=true;

    }

    this.view.forceLayout();

  }


});

Monday, March 30, 2020

How to do animation on onscroll of segment

Add following code on form postshow:

Sample code:

setAnimationforSeg:function(){
    var transformObject1 = kony.ui.makeAffineTransform();
    var transformObject2 = kony.ui.makeAffineTransform();
    transformObject1.translate(200, 0);
    transformObject2.translate(0, 0);
    var animationObject = kony.ui.createAnimation(
      {"0":{"transform":transformObject1,"stepConfig":{"timingFunction":kony.anim.LINEAR}},
       "100":{"transform":transformObject2,"stepConfig":{"timingFunction":kony.anim.LINEAR}}});
    var animationConfig = {
      duration: 1,
      fillMode: kony.anim.FILL_MODE_FORWARDS
    };
    var animationCallbacks = {"animationEnd":function(){kony.print("animation END");}};
    var animationDefObject={definition:animationObject,config:animationConfig,callbacks:animationCallbacks};
    this.view.segCategorylist.setAnimations({visible:animationDefObject});
  },

Notes:Replace your segment name instead of segCategorylist from code.

Thursday, August 8, 2019


Validation in server side


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="myprofile.aspx.cs" Inherits="myprofile" %> 
 
<!DOCTYPE html> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <script> 
        function OnlyNumbers(evt) { 
            var charCode = (evt.which) ? evt.which : evt.keyCode; 
            if (charCode != 46 && charCode > 31 
              && (charCode < 48 || charCode > 57)) 
                return false; 
            return true; 
        } 
        function checkEmail(event) { 
            var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 
            if (!re.test(event.value)) { 
                alert("Please enter a valid email address"); 
                return false; 
            } 
            return true; 
        } 
 
        function chkvalidation() 
        { 
            var exitval = false; 
            var rsltcount = 0; 
            var msgtext = ""; 
 
            //Age Validation 
            var ageval = document.getElementById("<%= txtAge.ClientID %>").value; 
            var agerslt = false; 
            if (ageval.length > 0) 
            { 
                agerslt = OnlyNumbers(document.getElementById("<%= txtAge.ClientID %>")); 
                if (agerslt == false) 
                { 
                    msgtext = "Invalid age entered."; 
                    rsltcount = 1 
                } 
                else 
                { 
                    if (ageval > 100) { 
                        msgtext = msgtext + "\n Check your entered age."; 
                        rsltcount += 1 
                    } 
                } 
            } 
            else 
            { 
                msgtext =  msgtext + "\n Invalid age or age required."; 
                rsltcount += 1 
            } 
             
            //Mobile Validation 
            var mobileval = document.getElementById("<%= txtMobile.ClientID %>").value; 
            var mobilerslt = false; 
            if (mobileval.length != 10) { 
                msgtext = msgtext + "\n Invalid mobile number or mobile number required"; 
                rsltcount += 1 
            } 
            else { 
                mobilerslt = OnlyNumbers(document.getElementById("<%= txtMobile.ClientID %>")); 
                if (mobilerslt == false) { 
                    msgtext = msgtext + "\n Invalid mobile number or mobile number required."; 
                    rsltcount += 1 
                } 
            } 
 
            //Email Validation 
            var emailidval = document.getElementById("<%= txtEmailID.ClientID %>").value; 
            var emailidrslt = false; 
           if (emailidval.length > 1) { 
                    emailidrslt = checkEmail(document.getElementById("<%= txtEmailID.ClientID %>")); 
                if (emailidrslt == false) { 
                    msgtext = msgtext + "\n Invalid email id entered."; 
                    rsltcount += 1 
                } 
            } 
            else { 
               msgtext = msgtext + "\n Email id required."; 
               rsltcount += 1 
            } 
 
            if (rsltcount > 0) 
            { 
                exitval = false; 
            } 
            else 
            { 
                exitval = true; 
            } 
             
            alert(msgtext); 
            return exitval; 
            } 
    </script> 
 
</head> 
<body> 
    <form id="form1" runat="server"> 
        <div> 
            <table> 
                <tr> 
                    <td>Name 
                    </td> 
                    <td> 
                        <asp:TextBox ID="txtName" runat="server" ClientIDMode="Static"></asp:TextBox> 
                    </td> 
                </tr> 
                <tr> 
                    <td>Age 
                    </td> 
                    <td> 
                        <asp:TextBox ID="txtAge" runat="server" onkeypress="return OnlyNumbers(event)" MaxLength="3"  ></asp:TextBox> 
                    </td> 
                </tr> 
                <tr> 
                    <td>Mobile 
                    </td> 
                    <td> 
                        <asp:TextBox ID="txtMobile" runat="server" MaxLength="10" onkeypress="return OnlyNumbers(event)" ></asp:TextBox> 
                    </td> 
                </tr> 
                <tr> 
                    <td>Email ID 
                    </td> 
                    <td> 
                        <asp:TextBox ID="txtEmailID" runat="server" placeholder="yourname@server.com" onblur="checkEmail(this)"></asp:TextBox> 
                    </td> 
                </tr> 
                <tr> 
                    <td rowspan="1"> 
                        <asp:Button ID="btnSubmit" Text="Submit" runat="server"  OnClick="btnSubmit_Click" OnClientClick="return chkvalidation()" /> 
                         
                    </td> 
                </tr> 
            </table> 
            <asp:Label ID="lblResultMessage" runat="server" Text=""></asp:Label> 
 
 
        </div> 
    </form> 
</body> 

</html>



using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text.RegularExpressions; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
public partial class myprofile : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
 
    } 
 
    protected void btnSubmit_Click(object sender, EventArgs e) 
    { 
        string MsgText = ""; 
        Int32 rsltcount = 0; 
 
 
        //Age Validation 
        bool ageValStatus = VerifyNumericValue(txtAge.Text); 
        if (ageValStatus == false) 
        { 
            rsltcount += 1; 
            MsgText += "Invalid age or age required.</br>"; 
        } 
        if (ageValStatus == true) 
        { 
            if(Convert.ToDecimal(txtAge.Text) > 100) 
            { 
                rsltcount += 1; 
                MsgText +=  " Check your entered age.</br>"; 
            } 
        } 
 
        //Mobile Validation 
        bool mobileValStatus = VerifyNumericValue(txtMobile.Text); 
        if (mobileValStatus == false) 
        { 
            rsltcount += 1; 
            MsgText += "Invalid mobile number or mobile number required.</br>"; 
        } 
        if (mobileValStatus == true) 
        { 
            if (txtMobile.Text.Length != 10) 
            { 
                rsltcount += 1; 
                MsgText += "Check your entered mobile number.</br>"; 
            } 
        } 
 
        //Email ID Validation 
        bool emailidValStatus = VerifyEmailID(txtEmailID.Text); 
        if (emailidValStatus == false) 
        { 
            rsltcount += 1; 
            MsgText += "Invalid email id or email id required.</br>"; 
        } 
 
        lblResultMessage.Text = MsgText; 
        lblResultMessage.Font.Bold = false; 
        lblResultMessage.Font.Size = 14; 
        lblResultMessage.ForeColor = System.Drawing.Color.Red;   
 
    } 
 
    public bool VerifyNumericValue(string ValueToCheck) 
    { 
        Int32 numval; 
        bool rslt = false; 
 
        rslt = Int32.TryParse(ValueToCheck, out numval); 
 
        return rslt; 
    } 
 
    public static bool VerifyEmailID(string email) 
    { 
        string expresion; 
        expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; 
        if (Regex.IsMatch(email, expresion)) 
        { 
            if (Regex.Replace(email, expresion, string.Empty).Length == 0) 
            { 
                return true; 
            } 
            else 
            { 
                return false; 
            } 
        } 
        else 
        { 
            return false; 
        } 
    } 
} 


GridView bind
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <table style="width:100%;"> 
        <tr> 
            <td> 
                 </td> 
            <td> 
                 </td> 
            <td> 
                 </td> 
        </tr> 
        <tr> 
            <td> 
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
                    CellPadding="4" DataKeyNames="id"> 
                    <Columns> 
                        <asp:TemplateField HeaderText="Name"> 
                            <EditItemTemplate> 
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("name") %>'></asp:TextBox> 
                            </EditItemTemplate> 
                            <ItemTemplate> 
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("name") %>'></asp:Label> 
                            </ItemTemplate> 
                        </asp:TemplateField> 
                        <asp:TemplateField HeaderText="City"> 
                            <EditItemTemplate> 
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("city") %>'></asp:TextBox> 
                            </EditItemTemplate> 
                            <ItemTemplate> 
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("city") %>'></asp:Label> 
                            </ItemTemplate> 
                        </asp:TemplateField> 
                    </Columns> 
                    <FooterStyle BackColor="#99CCCC" ForeColor="#003399" /> 
                    <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /> 
                    <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /> 
                    <RowStyle BackColor="White" ForeColor="#003399" /> 
                    <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /> 
                    <SortedAscendingCellStyle BackColor="#EDF6F6" /> 
                    <SortedAscendingHeaderStyle BackColor="#0D4AC4" /> 
                    <SortedDescendingCellStyle BackColor="#D6DFDF" /> 
                    <SortedDescendingHeaderStyle BackColor="#002876" /> 
                </asp:GridView> 
            </td> 
            <td> 
                 </td> 
            <td> 
                 </td> 
        </tr> 
        <tr> 
            <td> 
                 </td> 
            <td> 
                 </td> 
            <td> 
                 </td> 
        </tr> 
    </table> 
    <div> 
     
    </div> 
    </form> 
</body> 
</html> 



using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Data; 
using System.Data.SqlClient; 
 
public partial class Default2 : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!Page.IsPostBack) 
        { 
            refreshdata(); 
        } 
    } 
 
    public void refreshdata() 
    { 
        SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"); 
        SqlCommand cmd = new SqlCommand("select * from tbl_data", con); 
        SqlDataAdapter sda = new SqlDataAdapter(cmd); 
        DataSet ds = new DataSet(); 
        sda.Fill(ds); 
        GridView1.DataSource = ds; 
        GridView1.DataBind(); 
     
     
    }   
 
}  

Tuesday, February 19, 2019

setdataatt

ar:function (){

var obj={"lbl1":this.view.textbx.text}

var legthdata = this.view.seg.data;
syntax
------------------------------------------------------
dataObj1 = {globaDdataId1:"label1", globaDataId2:"label2", globalDataId3:"label3"};

//addAt method call ,adding the above row at 15th index position.
segment.addDataAt(dataObj1,15);
------------------------------------

this.view.segment.addDataAt(array,(legthdata.length));
}



alter way

var array =[];
ar:function (){
var cname = this.view.textbx.text;
var obj={"lbl1":this.view.textbx.text}
array.push(obj);
this.view.segment.removeAll();
this.view.seg.setdataAll(array);
}

Friday, February 8, 2019

how to do Push Notification

1.firebase console -> addproject -> create project ->android
2.kony visualizer ->projectSeting ->Native->Android-> packageName->
  pushnotification->select GCM.
3.take sha1key from google:
   {keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android}
  take debug keystore from system i.e sdk Path.
   {C:\Users\Truetech\.android\debug.keystore}
4.Cmd la paste.(SHA key gets generated.)
5.Open kpns-> add new app ->Application Name->Application ID we need to generate(note the app id for further use)->App Category :other-> next-> {android} ->GCM/FCM key ## firebase->settings->cloudmesseges
      -> Legacy server key-> save##

6.app should be published. ## main point##

7. In kpns Go to api help-> select {JSON} ->now we have baseURL and sample request .go to mfconsole do integration with the help of baseURL and sample request.
8. open  kony document kony.push.namespace-> senderid code-> Other coding.

/**
* Name : registerMyAndroidPush
* Author : Kony
* Purpose : This function registers the senderID on the Google cloud.
**/

function registerMyAndroidPush()
{
    var config = {senderid:"4815552342"};
    kony.push.register(config);
}




/**
* Name : regSuccessAndroidCallback
* Author : Kony
* Purpose : This function is the callback for the successful registration of the device to the GCM server. It returns the callerID.
*
**/

function regSuccessAndroidCallback(regId)
{
    kony.print("** JavaScript regSuccessCallback() called **");
    kony.print(regId);
}


/**
* Name : regFailureAndroidCallback
* Author : Kony
* Purpose : This function is the callback for the registration failure to the GCM server.
**/

function regFailureAndroidCallback(errormsg)
{
    kony.print("* JavaScript regFailureCallback() called *");
    kony.print(errormsg.failurereason]);
    kony.print(errormsg.description);
}

function onlinePushNotificationAndroidCallback(msg)
{
    kony.print("* JavaScript onlinePushNotificationCallback() called *");
    kony.print(msg);
    kony.print(msg.message);
}

/**
* Name : offlinePushNotificationAndroidCallback
* Author : Kony
* Purpose : This function is the callback for the received push msg event while offline
**/

function offlinePushNotificationAndroidCallback(msg)
{
    kony.print("* JavaScript offlinePushNotificationCallback() called *");
    kony.print(msg);
}

/**
* Name : unregSuccessAndroidCallback
* Author : Kony
* Purpose : This is the callback for the successful unregistration from the GCM server.
**/

function unregSuccessAndroidCallback()
{
    kony.print("* JavaScript unregSuccessCallback() called *");
}

/**
* Name : unregFailureAndroidCallback
* Author : Kony
* Purpose : This is the callback for the unsuccessful deregistration from the GCM server.
**/

function unregFailureAndroidCallback(errormsg)
{
    kony.print("* JavaScript unregFailureCallback() called *");
    kony.print(errormsg.errorcode);
    kony.print(errormsg.errormessage);
}


/**
* Name : callbackAndroidSetCallbacks
* Author : Kony
* Purpose : This function sets the callback for registration,deregistration and pushnotification events.
**/

function callbackAndroidSetCallbacks()
{
    kony.push.setCallbacks({
        onsuccessfulregistration: regSuccessAndroidCallback,
        onfailureregistration: regFailureAndroidCallback,
        onlinenotification: onlinePushNotificationAndroidCallback,
        offlinenotification: offlinePushNotificationAndroidCallback,
        onsuccessfulderegistration: unregSuccessAndroidCallback,
        onfailurederegistration: unregFailureAndroidCallback});
}




9. Do Changes in coding { Add alert to   #function onlinePushNotificationAndroidCallback#, #function regSuccessAndroidCallback#} 

10.create other new function and place this two functions 1.function callbackAndroidSetCallbacks 2.function registerMyAndroidPush
!!!!!!!!!!!!!!!!!!!!!!!!!!      call this function in postappinit        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

11.Change sender id in coding.   GET from ->firebase.


****

function pushNotificationNew(){
 
 callbackAndroidSetCallbacks();
  registerMyAndroidPush();
}

 *******
12.getting device id goto  mfconsole ->create new integration and paste base url FROM kpns API help URL and save and create operation (suffix no need).set method post

copy sample request from kpns

{
  "subscriptionService" : {
    "subscribe" : {
      "sid" : "xxxx",
      "appId" : "xxxx",
      "ufid" : "xxxx",
      "authToken" : "xxxx",
      "osType" : "xxxx",
      "deviceId" : "xxxx",
      "deviceName" : "xxxx"
    }
  }
}

pass input from (sample sid) from above json.here
___________________________________________________________
      "sid" : "123456"(anynumber),
      "appId" : ""(autogenerate kpns),
      "ufid" : "",
      "authToken" : "",
      "osType" : "android",
      "deviceId" : ""(can got it by ddms),
      "deviceName" : ""(your device name)
___________________________________________________________
 check by online gcm testing

give device token (device id)
app key(legecy sever key)
message("ha ha")


















*************************************************************************************************************************************
keytool -list -v -keystore C:\Users\somefolder\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
app id:132332-1992211795
*************************************************************************************************************************