Migration to SDK4

After Google's recent update to their User Data and Permissions policies, they have restricted access for SMS and Call Log permissions. As an alternative to SMS READ/RECEIVE permissions, we will depend on SMS Retriever API. As for SMS SEND/WRITE permissions, we will use SMS Intent to initiate SMS text messages.
Please follow the below documentation to migrate to SDK4.

Download SDK

Download Mobibox sdk 4 from link and add it to your project
https://goo.gl/MkcDp2


Manifest Changes
1- Remove SMS READ/RECEIVE/WRITE/SEND permissions from manifest.

2- Rename Meta-Data keys as below (com.mob instead of com.ma)
com.ma.ServiceId --> 
com.mob.ServiceId
com.ma.ClientGuid --> com.mob.ClientGuid
com.ma.ClientKey --> 
com.mob.ClientKey
com.ma.AppToken --> com.mob.AppToken
com.ma.Apk_CampaignId  --> com.mob.Apk_CampaignId

3- Rename SDK activities using new packageId of SDK (com.mob.sdk instead of com.ma.paymentsdk)
com.ma.paymentsdk.MA_BillingActivity -->  com.mob.sdk.MA_BActivity
com.ma.paymentsdk.SelectCountryActivity  --> 
com.mob.sdk.SelectCountryActivity

4- Add this new activity 
 <activity
            android:name="com.mob.sdk.TermsPrivacyActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"
            android:screenOrientation="portrait"/>

5- Remove intent filter to receive SMS and replace it with new one:
Remove:
<receiver android:name="com.ma.paymentsdk.broadcast.MA_MessageReceiver" >
    <intent-filter android:priority="1000" >
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver> 

Add:
<receiver android:name= "com.mob.sdk.broadcast.MA_MessageReceiver"
            android:exported="true"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.google.android.gms.auth.api.phone.SMS_RETRIEVED"/>
            </intent-filter>
</receiver>

Rename functions and classes in Host App

1- MA_BillingActivity -> MA_BActivity
2- MA_Billing -> MA_BInfo
3- MA_Billing.getBillingStatus --> MA_BInfo.getBStatus
4- lookup.LookUpSubscriber  --> lookup.LookUpUserStatus
5- public void lookupResult(int status, String Description, Boolean isFreeTrial, String subscriptionDate, String expiryDate)
to be replaced with:
public void lookupResult(int status, String Description, Boolean isTrial, String sDate, String eDate)
6- All imports should be changed from com.ma.paymentsdk --> com.mob.sdk

Add google-services.json

1-Add google-services.json file to your project.
2- Add the below in app level build.gradle
apply plugin: 'com.google.gms.google-services'
3- Add the below in top level build.gradle in dependencies
dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        classpath 'com.google.gms:google-services:4.0.1'
    }

Call GetOldSdkUserData 

Since new sdk has new packageId, it is necessary to transfer the data that was saved in old sdk into SDK4.
For that we will call getOldSdkUserData which will get user data from backend and save it to local variables in SDK4.

1- Declare MA_GetOldUserData getOldUserData;

2- First make sure your splashscreen implements MA_OnGetOldSdkUserData 

public class SplashScreenActivity extends AppCompatActivity
implements MA_OnLookUp, MA_OnGetOldSdkUserData {


3- In Splashscreen, wherever you check if user is MobileArts user (in branch IO onStart method), call the below method

if (DeeplinkUserFromMobileArts && MA_Utility.shouldCallGetOldSdkUserData(SplashScreenActivity.this)) {
callGetOldUserDataCheck();
} else {
navigateNext();
}

private void callGetOldUserDataCheck() {
getOldUserData = new MA_GetOldUserData(SplashScreenActivity.this);
getOldUserData.GetOldSdkUserData(SplashScreenActivity.this);
}

@Override
public void getOldSdkUserDataResult() {
    navigateNext();
}

private void navigateNext() {
if (MA_Utility.isOnline(SplashScreenActivity.this)) {
if (MA_BInfo.getBStatus(SplashScreenActivity.this)) {
callLookup();
} else if (user is mobile arts user){
Intent intent = new Intent(SplashScreenActivity.this, MA_BActivity.class);
startActivityForResult(intent, B_CODE);
} else{
//Continue with your flow
}
} else {
Toast.makeText(SplashScreenActivity.this, R.string.no_internet_connexion, Toast.LENGTH_LONG).show();
finish();
}
}

Sample project

For better understanding of the migration progress to SDK4, please download the sample project from the link below:
https://bitbucket.org/BIG_Genius/migration-to-sdk4/src/master/

Comments