跳到主要內容

How to integrate Push Notification/GCM + Admin Panel in your Existing APP

How to integrate Push Notification/GCM + Admin Panel in your Existing APP


Required java files for GCM integration Copy following file to your project
  1. News.Java  => used for internal news notification adapter
  2. GcmBrodcastRecive.java => the brodcast receiver for GCM notification receiver.
  3. GCM_Config.java=> the configuration file. contains your gcm SENDER_ID, SERVER_PATH. etc.
  4. DatabaseHandler.java => database handler to save news notifications offline.
  5. DialogeNotice.java => the dialog notification activity styled as dialog.
  6. CustomWebView.java => our own custom web activity for web notification
  7. Api_Web.java => helper class to use with network related stuff to register on to our server [use third party library : loopj asynctask]
  8. NoZoomControllWebView.java => our custom webview.Inserting Librariescopy this lib into your project -> libs folder
1. =>android-async-http-1.4.3.jar : used to call network related stuff . [Like sending our email with registration on our server] =>universal-image-loader-1.9.2.jar:used to load images from web into a imageview asyncronizly
Now from MainActivity.java file 
Copy following  functions to your main launcher activity [the activity which starts your App]
1.  isNetworkAvailable – return true/false according to your internet connectivity
2. checkPlayService – return true if google play serviece is available in the device [required for gcm serviece to work] -return false if not present
3. getAppVersion -return the current build code of app.
4. getRegistrationId -return the unique registration id for the app if stored previously by us. – otherwise return empty string
5. storeRegistrationId – store the current registraation id as per current app version. will be used to sync when app updated to newer version.
6. showAlert – show’s the alert dialog with given title and messege. will be use for notifying the user about progress or result of registration.
7.  registerInBackground – this method creates async task apart from main thread and generate unique registration gcm_id for app. and pass this information to backend via another method.
8. sendRegistrationIdToBackend – this method call the server API to store your unique gcm_id to your backend. and also update sharedpreference to avoid future request to our server.
Registering the receiver and serviece – Copy GcmBroadcastReceiver and GcmIntentService   to your project . you should change the package according to your project.
Chaniging the AndroidManifest file –
1. Add this permissions :
 <uses-permission android:name="android.permission.WAKE_LOCK" />
 <!-- This app has permission to register and receive data message. -->
 <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
 <!-- Permission to vibrate -->
 <uses-permission android:name="android.permission.VIBRATE" />
 <!-- Creates a custom permission so only this app can receive its messages. -->
 <permission
 android:name="com.icanstudioz.gcmintegration.permission.C2D_MESSAGE"
 android:protectionLevel="signature" />
 <uses-permission android:name="seradio.rfix.com.gcm.permission.C2D_MESSAGE" />
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
2. Adding Activity , Services, and Brodcaster
 <activity
 android:name="radioklub.sekhontech.com.gcm.DailogeNotice"
 android:theme="@style/AppTheme.Dialog" >
</activity>

 <activity
 android:name="radioklub.sekhontech.com.gcm.CustomeWebView">
 </activity> 
 <activity 
 android:name="com.google.android.gms.ads.AdActivity"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<receiver android:name="radioklub.sekhontech.com.gcm.GcmBroadcastReceiver" 
 android:permission="com.google.android.c2dm.permission.SEND" >
 <intent-filter>
 <!-- Receives the actual messages. -->
 <action android:name="com.google.android.c2dm.intent.RECEIVE" />
 <category android:name="radioklub.sekhontech.com.gcm" />
 </intent-filter>
</receiver>
<service android:name="radioklub.sekhontech.com.gcm.GcmIntentService" />
3. Adding Metatag of google play service
Add this under <application tag
 <meta-data
 android:name="com.google.android.gms.version"
 android:value="@integer/google_play_services_version" />
Adding values and styles
copy      res -> values -> string.xml
and        res-> values ->style.xml
data
and paste to your relevant xml files. [do not overwrite this files]
Adding drawables and layouts
copy      res -> drawables
and        res-> layouts
Posted on September 2, 2015 in Uncategorized

這個網誌中的熱門文章

正確設置404頁面及其他.505,500....

正確設置404頁面 404頁面的設置是否正確直接關係到網站粘性,而現在很多網站的錯誤頁面返回碼都是200和302,只要蜘蛛爬行錯誤頁面不是404,那麼你的404頁 面設置就是錯誤的了,這裡跟大家介紹如何正確設置404頁面。 怎麼正確設置404頁面?很多人看到這個話題可能覺得下文不屑一顧,其實你是否知道自己的404頁面有沒有設置正確呢?很多開源的cms系統和博客 系統都會帶有404頁面,你是不是覺得這樣已經ok了?不用設置了?這些想法是錯誤的,我們做優化的時候,應該測試404頁面時候生效,設置是否正 確等。下面我們詳細說明怎麼設置404頁面。 這先說一下怎麼樣的404頁面才是有效的404頁面。大家應該都知道搜索引擎是通過http狀態碼來識別網頁狀態的,那麼當蜘蛛檢索到一個錯誤鏈 接時,就需要返回404狀態碼來告訴搜索引擎,這個頁面是錯誤頁面,以後不用索取了。而如果返回200,則告訴搜索引擎這個頁面是正常頁面。 所以我們要查看網站錯誤頁面的返回碼是200還是404,而現在很多網站的404頁面返回碼是200而不是404.    那怎麼正確設置404頁面?

Mac OS X Server 架設兩個網站、兩個郵件伺服器

from:http://www.bnw.com.tw/conference/viewtopic.php?t=208 我的需求要更簡單。  朋友的工作室就兩三人而已,另外一個工作室也是兩三人。  希望有屬於自己的網站及網域名稱郵件  www.123.com   abc@123.com  

Mac mini server(2012 年末和 2011 年中):如何將 OS X Server 安裝到軟體 RAID

重要事項 這些步驟會清除 Mac mini Server 中兩個磁碟機上的所有資料。雖然您可以重新安裝 OS X Server,但是請務必確認這些磁碟機上的任何其他資料都已完成備份,然後再繼續。 您無法在 RAID 卷宗上建立恢復分割區。如果沒有恢復分割區, 將無法支援 OS X 的某些功能 ,因此您應該考慮使用 恢復磁碟輔助程式 建立外接恢復磁碟,然後才建立 RAID 卷宗。 本文所提供的步驟需要使用透過 WiFi 或乙太網路的寬頻 Internet 連線。您的網路連線必須符合 這篇連結文章 的「重新安裝 OS X 的需求」一節中,針對 Internet 回復功能所述的需求。 安裝步驟 按住 Command、Option 和 R 鍵的同時啟動 Mac mini Server,以便啟動進入 Internet 回復模式。這可能要花數分鐘的時間。看到旋轉地球和“正在從網路啟動回復程序”訊息時,放開這些按鍵。