User Tools

Site Tools


antispam_integration

This is an old revision of the document!


Integrating Antispam Apps with SDMM

Antispam apps are classifed as apps that block messages from the user's standard text messaging app. These apps simply block messages, and in some cases they respond to the sender according to the user's setup in the antispam app. Your app will not have permission to modify existing messages in the SMS database. If your app requires this feature either select a different Access Type or contact us for premium access details.

SDMM allows your app to abort messages prior to being processed by a full-featured messaging app. When you integrate and register with SDMM, SDMM will notify your app of any incoming messages prior to them being processed by the full-featured app.

To integrate with SDMM, do the following:

1. Download and import the SDK into your IDE. You will need to include the SDK as a library in your app's project.

2. In a strings file in /res, add your SDSMS_ID:

<string name="SDSMS_ID">YOUR_APP_KEY</string>

Replace your registration ID with “YOUR_APP_KEY”.

3. With each SMS, SDMM will send a duplicate SMS broadcast with a “DUPLICATE” extra. When your app recognizes an incoming SMS/MMS that should be blocked, check the SMS intent for the SDMM extra “DUPLICATE” so your app can signal SDMM that the message should be aborted. To block the message, check for the DUPLICATE extra and abort the broadcast like this:

String sdmmDup = "";
if (intent.hasExtra(SDSmsConsts.SDSMS_DUPLICATE)) sdmmDup = SDSmsConsts.SDSMS_DUPLICATE;
if (!SDSmsConsts.SDSMS_DUPLICATE.equals(sdmmDup)) {
      // your code here
} else {
      setResultCode(0);
      setResultData(SDSmsConsts.SDSMS_ABORT);
}

Setting the appropriate result code and result data will tell SDMM that the message should not propagate further. It will not be written to the SMS database.

3. If your app sends a response to an aborted message that you do not want written to the SMS database, you can send the message using SDSmsManager. In your app, replace SmsManager with SDSmsManager anywhere you use it in your project. If you set it globally in an Application class, that will work too. For example replace:

SmsManager mSmsManager = SmsManager.getDefault();

with this:

SDSmsManager mSDSmsManager = SDSmsManager.getDefault(context, context.getString(R.string.SDSMS_ID),
      SDSmsManager.ACCESS_TYPE_ANTISPAM);

4. Replace all SmsManager calls with SDSmsManager calls, like this:

SDSmsManager sms = SDSmsManager.getDefault(context, context.getString(R.string.SDSMS_ID), SDSmsManager.ACCESS_TYPE_MESSAGING);
try {
	sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
} catch (Exception e) {
	// error sending message, notify user and update database sendError(msgId, phoneNumber);
}

5. If you use a SqliteWrapper, like many examples that are readily available, simply replace you import statement in those classes with the following:

import com.sdmmllc.superdupersmsmanager.database.sqlite.SqliteWrapper;

The included class does URI resolution normally except that the standard “sms” authority is replaced with the “sdsms” authority. When SDMM is the Default Messaging App, SDMM will handle the call. If another app is the Default Messaging App, it will resolve to the standard “sms” authority and your response message will be written to the SMS database.

antispam_integration.1394870112.txt.gz · Last modified: 2014/03/15 07:55 by superdupersms