xtify.com and B4A

dealsmonkey

Active Member
Licensed User
Longtime User
Hi everyone,

I am in need of a push service for an app and have looked at xtify.com. A couple of questions,

1. I assume a library could be written for this as it is a standard .jar, before I get my "hands dirty" trying to write a wrapper !!
2. Anyone have any better alternatives ? I have looked at the googlecloud option, but see it is still in limited registration.

Thanks in advance

Neil
 

dealsmonkey

Active Member
Licensed User
Longtime User
Great work Dealsmonkey!

If you don't mind, could you send me the library java code than as I want to see how it exactly works cause I really don't understand anything of wrapping or smth. Ofcourse, Credits will go to you ;)

good job,
XverhelstX

B4X:
import android.content.Context;
import anywheresoftware.b4a.AbsObjectWrapper;
import anywheresoftware.b4a.BA;

import com.xtify.android.sdk.PersistentLocationManager;

@BA.ActivityObject
@BA.ShortName("nejoXtify")
@BA.Author("njl")
public class nejoXtify extends AbsObjectWrapper<PersistentLocationManager> {
   
   private String eventName;
     private BA ba;
      
   public void initialise(BA ba, String eventName){
                  
      this.ba = ba;      
      Context context = ba.context;      
      final PersistentLocationManager plm = new PersistentLocationManager(context);
      
      plm.showSettingsActivity(context, true);
      
      Thread xtifyThread = new Thread(new Runnable() {
          @Override
          public void run() {
             String s = "";
             
             
            //  plm.setNotificationIcon(BA.applicationContext.getResources().getIdentifier(s, "drawable", BA.packageName));
             
                    
             
             plm.setNotificationIcon(17301577);
             plm.setNotificationDetailsIcon(17301577);
              boolean trackLocation = plm.isTrackingLocation();
              boolean deliverNotifications = plm.isDeliveringNotifications();
              if (trackLocation || deliverNotifications) {
                  plm.startService();
              }
          }
      });
      xtifyThread.start();
      
   } //End Initialise   

} //End Class

As I mentioned, there is still a long way to go !!.
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
Ok, thank you very much.

So first of all, you shouldn't forget to add the permissions:
B4X:
@Permissions(values={"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION", "android.permission.RECEIVE_BOOT_COMPLETED", "android.permission.READ_PHONE_STATE", "android.permission.ACCESS_NETWORK_STATE", "android.permission.INTERNET", "android.permission.ACCESS_WIFI_STATE", "android.permission.CHANGE_WIFI_STATE", "android.permission.VIBRATE"})

This way people won't have to add these permissions to their android manifest.

Also add a package declaration at the top:

package com.example.xtifypushlib;

Maybe remove the @ActivityObject annotation, this way, it will work in services. So people will receive them when their screen is locked.

I assume people would have to manually add everything to the Android Manifest? :s

B4X:
<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="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.Vxxxx" />
    </intent-filter>
</service>
<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" />
        <!-- 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="/YOUR_APP_KEY_GOES_HERE" />
    </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="YOUR_APP_KEY_GOES_HERE" />

For the strings.xml I assume you can do the following:

Make a map "values" in your map "res" and name it "strings.xml" (Make sure it's not strings.xml.txt.) and copy the following in there:
B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- settings screen -->
   <string name="enableNotificationsTitle">Enable notifications</string>
   <string name="enableNotificationsSummary">Enables or disables notifications notifications</string>
   <string name="locationTrackingCategoryTitle">Location Updates</string>
   <string name="locationTrackingTitle">Enable location updates</string>
   <string name="locationTrackingSummary">Sends location updates to the server for more relevant notifications</string>
   <string name="locationTrackingFrequencyTitle">Usage frequency</string>
   <string name="locationTrackingFrequencySummary">Specify the number of minutes</string>
   <string name="gpsUsageCategoryTitle">GPS</string>
   <string name="gpsUsageTitle">Use GPS when available</string>
   <string name="gpsUsageSummary">Uses GPS  when more accurate location updates are necessary</string>
   <string name="gpsUsageFrequencyTitle">Usage frequency</string>
   <string name="gpsUsageFrequencySummary">Specify the number of minutes</string>
 
<!-- notification details screen -->
   <string name="settingsButtonLabel">Settings</string>
   <string name="iLikeButtonLabel">I Like</string>
   <string name="iDontLikeButtonLabel">I Dont Like</string>
   <string name="moreInfoButtonLabel">More Info</string>
   <string name="shareButtonLabel">Share / Save</string>
   <string name="mapButtonLabel">Map</string>
   <string name="shareNotificationDialogTitle">Share notification via</string>
</resources>

I think this is the only thing I know more about this.

Thanks,

XverhelstX
 
Upvote 0
Top