Xtify Library V1.0

dealsmonkey

Active Member
Licensed User
Longtime User
Hi Everyone,

Sorry for the delay in posting, but here is my first version of a library to connect to xtify push services.

For those who do not know the service, go to Xtify: Free Push Notifications for iOS (iPhone, iPad), Android and Blackberry devices | Xtify

Firstly extract the 4 files and copy them both to your add libraries folder, then tick them both in the B4A Libs pane. They are nejoXtify.jar & nejoXtifylib.jar, nejoXtify.xml & nejoXtifylib.xml

The library has only 2 calls from within B4A :

1. initialize("EventName")
2. ShowSettings("")

Here is an example of the initilize method :

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
      
   Dim xtify As NejoXty   
End Sub

Sub Service_Create
xtify.initialize("xtify")
End Sub


Sub xtify_xtfymessagereceived(title As String, body As String)
Log("Message : " & title & "  " & body)
ToastMessageShow(Title & body,False)
End Sub

As you can see, this method is called in a service module and the _xtfymessagereceived() sub is used to listen for the message and act upon what is received, a title and a body. That is all that is needed to register the device with xtify and listen for messages :sign0060:

When you run your app, you will see the device in "Test Implementation" section of the xtify website. Just send a message and voila a toast will appear !!

The Second Method ShowSettings(""), must be run within an activity and is used to show the xtify custom preferences activity. Here is an example :

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
                     
   Dim Button1 As Button      
   Dim xty As nejoXtyShowSettings
   
End Sub


Sub Button1_Click
xty.ShowSettings("")   
End Sub

That is it for the preferences activity, the library handles storing the preference data etc..

The final part of the library is setting your manifest.xml file. Once the lines are added, make the manifest.xml read only or use the "do not overwrite the manifest" option in B4A.

The details for this are here : How to Integrate Android Push

The only important thing to remember is that if you want to use the custom notification as used in the first example here, then add these lines to the manifest.xml

B4X:
<receiver android:name="com.nejo.android.xtify.NejoXtyreceiver">
       <intent-filter android:priority="9999">
             <action android:name="com.xtify.android.sdk.SHOW_NOTIFICATION" />
             <!-- KEEP THE FORWARD SLASH IN FRONT OF THE APP KEY ON THE LINE BELOW -->
             <data android:scheme="notif" android:host="notification.xtify.com" 
 android:pathPrefix="/YOUR-APP-KEY-HERE" />
       </intent-filter>
 </receiver>

This is an alternative push solution to Erel's excellent Google C2DM implementation, offering different facilities for the developer to interact with their app users. The technology uses xmpp push technology and seems fine at minimal battery use with instant push messages.

Let me know if you have any problems.

Neil
 

Attachments

  • nejoXtify.zip
    265.4 KB · Views: 350
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Having some trouble with the API key, it says it cannot find META information.

Below is sample what I use in manifest:

<service android:name="svcxtify"></service>
<receiver android:name="svcxtify$svcxtify_BR">
</receiver>
<receiver android:name="com.nejo.android.xtify.NejoXtyreceiver">
<intent-filter android:priority="9999">
<action android:name="com.xtify.android.sdk.SHOW_NOTIFICATION" />
<!-- KEEP THE FORWARD SLASH IN FRONT OF THE APP KEY ON THE LINE BELOW -->
<data android:scheme="notif" android:host="notification.xtify.com" android:pathPrefix="/mykey" />
</intent-filter>
</receiver>
 

dealsmonkey

Active Member
Licensed User
Longtime User
Having some trouble with the API key, it says it cannot find META information.

Below is sample what I use in manifest:

<service android:name="svcxtify"></service>
<receiver android:name="svcxtify$svcxtify_BR">
</receiver>
<receiver android:name="com.nejo.android.xtify.NejoXtyreceiver">
<intent-filter android:priority="9999">
<action android:name="com.xtify.android.sdk.SHOW_NOTIFICATION" />
<!-- KEEP THE FORWARD SLASH IN FRONT OF THE APP KEY ON THE LINE BELOW -->
<data android:scheme="notif" android:host="notification.xtify.com" android:pathPrefix="/mykey" />
</intent-filter>
</receiver>


Sorry for the delay in replying, I'll check it out.
 

dealsmonkey

Active Member
Licensed User
Longtime User
Having some trouble with the API key, it says it cannot find META information.

Below is sample what I use in manifest:

<service android:name="svcxtify"></service>
<receiver android:name="svcxtify$svcxtify_BR">
</receiver>
<receiver android:name="com.nejo.android.xtify.NejoXtyreceiver">
<intent-filter android:priority="9999">
<action android:name="com.xtify.android.sdk.SHOW_NOTIFICATION" />
<!-- KEEP THE FORWARD SLASH IN FRONT OF THE APP KEY ON THE LINE BELOW -->
<data android:scheme="notif" android:host="notification.xtify.com" android:pathPrefix="/mykey" />
</intent-filter>
</receiver>


Are you also adding the other sections in the manifest as shown in the Xtify Docs ?
 

dealsmonkey

Active Member
Licensed User
Longtime User
Here is the complete manifext from my test app :


B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.exg.xtify"
      android:versionCode="1"
      android:versionName=""
     android:installLocation="preferExternal">
      <uses-sdk android:minSdkVersion="4" />
      <supports-screens
          android:largeScreens="true"
          android:normalScreens="true"
          android:smallScreens="true"
          android:anyDensity="true"/>
                

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
        
        
        
    <application android:icon="@drawable/icon" android:label="xtify">      
      
      
      
      
        <activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main"
                  android:label="xtify" android:screenOrientation="unspecified">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        
<activity 
    android:name="com.xtify.android.sdk.SettingsActivity" 
    android:label="Settings"
    >
</activity>
<activity 
    android:name="com.xtify.android.sdk.NotificationDetailsActivity" 
    android:label="Notification Details"
 android:screenOrientation="portrait"  
    >
</activity>
<activity 
    android:name="com.xtify.android.sdk.NotificationSettingsActivity" 
    android:label="Notification Settings"
    >
</activity>

<service android:name="getxtify"></service>
<receiver android:name="getxtify$getxtify_BR">
</receiver>


<service 
    android:name="com.xtify.android.sdk.MainService"
    android:label="Notifications Service" 
    >
    <intent-filter>
        <action android:name="com.xtify.android.sdk.IMainService" />
        <category android:name="com.xtify.android.sdk.IMainService" />
        <category android:name="com.xtify.android.sdk.IMainService.V1050" />
    </intent-filter>
</service>

<receiver android:name="com.nejo.android.xtify.NejoXtyreceiver">
       <intent-filter android:priority="9999">
             <action android:name="com.xtify.android.sdk.SHOW_NOTIFICATION" />
             <!-- KEEP THE FORWARD SLASH IN FRONT OF THE APP KEY ON THE LINE BELOW -->
             <data android:scheme="notif" android:host="notification.xtify.com" 
 android:pathPrefix="/1aa038b8-ee48-49ea-a1a0-b7863bca6563" />
       </intent-filter>
 </receiver>


<receiver android:name="com.xtify.android.sdk.MainReceiver">
    <intent-filter>
       <action android:name="com.xtify.android.sdk.SHOW_NOTIFICATION" /> 
        <action android:name="com.xtify.android.sdk.NOTIFICATION_CLICKED" />
        <action android:name="com.xtify.android.sdk.NOTIFICATION_CLEARED" />
      <action android:name="com.xtify.android.sdk.SAVE_REGISTERED_CP_ID" />
        <action android:name="com.xtify.android.sdk.SAVE_USER_KEY" />
        <!-- MAKE SURE THE APP KEY ON THE NEXT LINE IS PRECEDED BY A SLASH -->
        <data android:scheme="notif" android:host="notification.xtify.com" 
android:pathPrefix="/app-key" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
        <action android:name="com.xtify.android.sdk.SEND_SETTINGS" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <action android:name="android.intent.action.PACKAGE_REMOVED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>



<meta-data android:name="XTIFY_SDK_API_KEY" android:value="app-key" />

    </application>
   

</manifest>

Just replace the package name "com.exg.xtify" to your own package name.
 
Top