Android Push Notification of the New GCM release using Coldfusion


is there similar push notification solution/tutorial time android?

something similar tutorial android gcm using coldfusion send dedicated server registered devices:

http://www.raymondcamden.com/index.cfm/2010/9/13/guest-post-apple-push -notifications-from-coldfusion-in-ten-minutes-or-less

thanks in advance

talal

well after diving , testing here , there found way , tested.

1> first , formost, developer need follow procedures in page:

http://developer.android.com/guide/google/gcm/gs.html

2> in app side, send users devices information; matters "registration id" , make sure save in database coz you'll use loop through database records when sending notifications.

3> server side script in coldfusion easy:

<!---place above html tag--->

<cfsetting requesttimeout="80000000000000">

<cfset appname = 'yourappname'>

<cfset registrationarray = arraynew(1)>

<cfquery datasource="devicesdsn" name="rscount">

    select count(intgcmuserid) totalrecords

    gcmusers_tbl

    appname = <cfqueryparam cfsqltype="cf_sql_clob" value="#appname#">

</cfquery>

<!---google limited send 1000 devices @ time need nest cfloop of array inside cfloop pertaining our total recordcount recordset we'll use ceiling control number of loops needed make sure sent users if exceed google limit--->

<cfset loopingno = ceiling(rscount.totalrecords/1000)>

<cfset fromrec = 1>

<cfset torec = 1000>

 

<!---now place following code inside body tag of cfm page--->

 

<cfif isdefined("form.pushbutton")>

    <cfquery datasource="devicesdsn" name="rs">

    select regid

    gcmusers_tbl

    appname = <cfqueryparam cfsqltype="cf_sql_clob" value="#appname#">

    order intgcmuserid desc

    </cfquery>

    <cfloop from="1" to="#loopingno#" index="i">

        <cfloop query="rs">

            <cfset arrayappend(registrationarray, "#regid#")>

        </cfloop>

        <cfset stfields =

        { "data"= {

            "title" = "#form.title#",

            "message"= "#form.message#"

          },

          "registration_ids"= #registrationarray#

        }

        >

        <cfhttp url="https://android.googleapis.com/gcm/send" method="post" result="httpresp" timeout="600">

            <cfhttpparam type="header" name="content-type" value="application/json"/>

            <cfhttpparam type="header" name="authorization" value="key=yourapikeyfromgoogle">

            <cfhttpparam type="body" value="#serializejson(stfields)#">

        </cfhttp>

        <cfset temp = arrayclear(registrationarray)>

        <cfset fromrec = fromrec + 1000>

        <cfset torec = torec + 1000>

    </cfloop>

    <h2 align="center" style="color:red;">sent to: <cfoutput>#rs.recordcount#</cfoutput> devices/users </h2>

    <h3 align="center"><a href="thispage.cfm">&gt;&gt;&gt;again</a></h3>

<cfelse>

<cfform>

  <table width="400" border="1" align="center" cellpadding="2" cellspacing="2">

    <tr valign="top">

      <th scope="row">title:</th>

      <td><label for="title"></label>

      <cfinput type="text" name="title" required="yes" id="title" maxlength="30" width="300" message="type title"></td>

    </tr>

    <tr valign="top">

      <th scope="row">message:</th>

      <td><label for="message"></label>

      <cftextarea name="message" cols="45" rows="2" required="yes" id="message" maxlength="120" message="type message"></cftextarea></td>

    </tr>

    <tr>

      <th scope="row"> </th>

      <td><cfinput type="submit" name="pushbutton" value="send" id="pushbutton"></td>

    </tr>

  </table>

</cfform>

</cfif>



More discussions in ColdFusion


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

PProHeadless.exe has stopped working error when opening projects in Adobe Media Encoder CS6

Preconditions Failed. - Joomla! Forum - community, help and support