Sample Code


We have to add permissions, activities(Which are used in XNotify), receiver which receive push-notification into your project and gcm intent service into manifest file (Note these manifest addition are compulsory).

Below are the permissions to add into manifest file:


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

<uses-permission android:name="android.permission.WAKE_LOCK" />

<permission
android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Below are two activities to add into manifest file:

<activity
android:name="com.comnez.XNotify.XNotifyActivity" android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="com.comnez.XNotify.EventFragment"
android:screenOrientation="orientation | screenSize" />



Below is the receiver to add into manifest file:


<receiver
android:name="com.comnez.XNotify.utilities.PushLibraryBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" />
<intent-filter />
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="YOUR_PACKAGE_NAME" />
</intent-filter />
</receiver />



Below is the service to add into manifest file:

<service android:name="com.comnez.XNotify.GCMIntentService" />




Now choose the point in your project from where you want to add XNotify functionality, like at any button Action or after navigation of any screen or elsewhere you want to.

Now import these two classes where you want to set entry point for XNotify

import com.comnez.XNotify.XNotifyActivity;

import com.comnez.XNotify.utilities.XNotifyThemeConfig;

At last with the help of below just two lines you will be ready to get push-notification


XNotifyActivity oXNotifyActivity = new XNotifyActivity();

oXNotifyActivity.getNotificationList(YOUR_ACTIVITY_CONTEXT, "YOUR_CLIENT_NAME");

The getNotificationList method above will accept two parameters

1. YOUR_ACTIVITY_CONTEXT

2. YOUR_CLIENT_NAME (String)


You will get "Sample App" with download stuff, for XNotify integration. You "Sample App" look like below:

 

 

In above image "Notifications" button is the entry point for XNotify notification center. You can change the entry point as per you need.

Below is the default color theme for XNotify inbox:

 

1. You can change Header color by calling the method :

XNotifyThemeConfig.setHeaderColor("STRING_COLOR_CODE");

In this method you have to provide just color code string eg. #ff00ff.

The changed Header will be like below:

 

2. You can change Header text color by calling the method:

XNotifyThemeConfig.setHeaderTextColor("STRING_COLOR_CODE ");

In this method you have to provide just color code string eg. #ff00ff.

The changed Header Text Color will be like below:

 

 

3. You can change Header text size by calling the method:

XNotifyThemeConfig.setHeaderTextSize(INT_FOR_HEADER_LABEL_SIZE);

In this method you have to provide just size as int eg. 17

The changed Header Text Size will be like below:

 

4. You can change Header text typeface (font) by calling the method:

XNotifyThemeConfig.setHeaderTypeface("FONT_NAME_FOR_HEADER_TEXT_FROM_ASSETS");

In this method you have to provide just font name as string eg some_font (If you have some_font.ttf in assets folder).

The changed Header Text Typeface(Font) will be like below:

 

5. You can change background color of List Item by calling the method:

XNotifyThemeConfig.setListItemColor("STRING_COLOR_CODE");

In this method you have to provide just color code string.

The changed List Item will be like below:

 

6. You can change List Item title text size by calling the method:

XNotifyThemeConfig.setListItemTitleTextSize(INT_FOR_HEADER_LABEL_SIZE);

In this method you have to provide just size as int eg. 17

The changed List Item Title Text Size will be like below:

 

7. You can change List Item title text typeface (font) by calling the method:

XNotifyThemeConfig.setListItemTitleTextTypeface("FONT_NAME_FOR_HEADER_TEXT_FROM_ASSETS");

In this method you have to provide just font name as string eg some_font (If you have some_font.ttf in assets folder).

The changed List Item Title Text Typeface(Font) will be like below:

 

Back to Top

Copyright © 2024 Comnez Inc. All rights reserved.