@guide https://proandroiddev.com/publishing-android-libraries-to-mavencentral-in-2021-8ac9975c3e52
@Create Release gradlew warply-android-sdk:publishReleasePublicationToSonatypeRepository
@Close and Release Repository gradlew closeAndReleaseSonatypeStagingRepository
Prerequisites • Android 6 or greater • Android Studio 3.6 or greater • JDK 8 or greater
Installation
Top level build.gradle In repositories section of the buildscript and the allProjects block add mavenCentral()
Module level build.gradle dependencies { implementation 'ly.warp:warply-android-sdk:4.5.0' }
Configuration - SDK We need to add to the assets folder the below file warply.properties
Uuid The app uuid the warply sdk need to connect to the engage server Business section will provide it for you Debug If we need to see logs in Logcat BaseURL Production or Development environment of the engage server Production: https://engage.warp.ly Development: https://engage-stage.warp.ly ProgressColor Replace the color with one you want the progress bar to have depending on you app theme coloring If not defined the colorPrimary will be used ProgressDrawable Replace the drawable with one you want (this will show when webview loading) If not defined the launcher icon will be used PushColor If not defined the colorPrimary will be used PushIcon If not defined the launcher icon will used (better use the clipart icons for support black/white icons on 24+) PushSound If not defined the default will be used SendPackages If the device packages need to be send to the engage server Language The app language MerchantId The merchant id for some requests LoginType The login type must be one of the below: email, msisdn, username DL_URL_SCHEME Only for react native app The deeplink url scheme for react native campaigns
Configuration - Push Notifications (FCM/HMS)
Top level build.gradle In repositories section of the buildscript and the allProjects block add maven { url 'https://developer.huawei.com/repo/' } This is only for HMS
Top level build.gradle In dependencies section add classpath 'com.google.gms:google-services:4.3.10' classpath 'com.huawei.agconnect:agcp:1.6.2.300'
Module level build.gradle, at the top of it add apply plugin: 'com.google.gms.google-services' apply plugin: 'com.huawei.agconnect'
Inside the app folder we need to add each or both json file(s) google-services agconnect-services
Initialization
- In the starting activity of the application (i.e SplashActivity), we have to add the lines below
1a. private WarplyInitializer mWarplyInitializer; 1b. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash);
mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() {
@Override
public void onWarplyReady() {
//Maybe go to next Activity or whatever
}
@Override
public void onWarplyInitTimeOut() {
}
@Override
public void onWarplyPermissionsDenied() {
}
});
}
1c. @Override protected void onResume() { super.onResume(); mWarplyInitializer.initWithPermissions(this); } 1d. If we have a BaseActivity that other activities extend it, optionally (or in the starting activity), we can track when our application created, resumed or paused.
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WarplySessionManager.onCreateActivity(this); }
@Override protected void onStart() { super.onStart(); WarplySessionManager.onStartActivity(this); }
@Override protected void onStop() { super.onStop(); WarplySessionManager.onStopActivity(this); }
Requests
- Campaigns
Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
private CallbackReceiver mInboxReceiver = new CallbackReceiver() { @Override public void onSuccess(CampaignList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Products
The “gift” parameter refers to the category of the product (gift, fruit, other custom category etc) that has been created on the engage platform. Empty parameter or without the .setProductFilter method, we will get all the products from all categories that have been created on the engage platform.
- The setLanguage method is used to search on the language we provide. WarplyManager.getProducts(new WarplyProductsRequest().setProductFilter("gift"), mProductsReceiver);
private CallbackReceiver mProductsReceiver = new CallbackReceiver() { @Override public void onSuccess(ProductList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Merchants
Better use (30 : Merchants Multilingual request) WarplyManager.getMerchants(new WarplyMerchantsRequest(), mShopsReceiver);
private CallbackReceiver mShopsReceiver = new CallbackReceiver() { @Override public void onSuccess(MerchantList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Content
The “Article” parameter refers to the category that each content has been created on the engage platform. Empty parameter or without the .setContentCategory method, we will get all content from all categories that have been created on the engage platform. Respectively and in combination with content category we also have the .setTags method that refers to keywords every content item may has (i.e fun, beach, book etc).
- The .setTags method takes an list with keyword names as string.
- The setLanguage method is used to search on the language we provide. WarplyManager.getContent(new WarplyContentRequest().setContentCategory("Article").setTags(ArrayList), mContentReceiver);
private CallbackReceiver mContentReceiver = new CallbackReceiver() { @Override public void onSuccess(ContentList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Merchant Categories
Returns the merchant categories the merchants belong to.
- The setLanguage method is used to search on the language we provide. WarplyManager.getMerchantCategories(new WarplyMerchantCategoriesRequest(), mShopCategoriesReceiver);
private CallbackReceiver mShopCategoriesReceiver = new CallbackReceiver() { @Override public void onSuccess(MerchantCategoriesList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Tags Categories
Returns the categories of the tags that has been created on the engage platform.
- The setLanguage method is used to search on the language we provide. WarplyManager.getTagsCategories(new WarplyTagsCategoriesRequest(), mTagsCategoriesReceiver);
private CallbackReceiver mTagsCategoriesReceiver = new CallbackReceiver() { @Override public void onSuccess(TagsCategoriesList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Tags
Returns the tags that has been created on the engage platform. Each tag item includes a category kay so in combination with the (6) to know in which category it belongs to. Each tag item has a name and a uuid key. The name can be used in (4 : setTags) and the uuid in (31 : setTags).
- The setLanguage method is used to search on the language we provide. WarplyManager.getTags(new WarplyTagsRequest(), mTagsReceiver);
private CallbackReceiver mTagsReceiver = new CallbackReceiver() { @Override public void onSuccess(TagsList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Contact
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.sendContact(new WarplyContactRequest() .setContactSubject("Other") .setContactName("Testaros") .setContactEmail("test@test.com") .setContactNumber("") .setContactMessage("Test comments"), mContactReceiver);
private CallbackReceiver mContactReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Login
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The .setId method must be one of email, msisdn or username and refers to the LoginType in warply.properties file. WarplyManager.login(new WarplyLoginRequest() .setId("email/msisdn/username") .setPassword(""), mLoginReceiver);
private CallbackReceiver mLoginReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Register
The .setId and .setPassword methods are mandatory. The .setAutologin method is used if we want to autologin after the successful register flow. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.register(new WarplyRegisterRequest() .setAutologin(true) .setId("panost+6@warp.ly") .setPassword("123456") .setFirstName("Test") .setLastName("Test") .setEmail("test@test.com") .setMsisdn("1234567890") .setSalutation("Mr") .setNickname("Testaros") .setGender("male") .setBirthDate("01/01/1970") .setNewsletter(false) .setSms(false) .setPersonalizedNewsletter(true) .setPersonalizedSms(true), mRegisterReceiver);
private CallbackReceiver mRegisterReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- User Profile
We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
private CallbackReceiver mConsumerReceiver = new CallbackReceiver() { @Override public void onSuccess(Consumer result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Logout
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.logout(mLogoutReceiver);
private CallbackReceiver mLogoutReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Change Password
WarplyManager.changePassword(new WarplyChangePasswordRequest() .setOldPassword("123456") .setNewPassword("1234567"), mChangePasswordReceiver);
private CallbackReceiver mChangePasswordReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Edit User Profile
We have to be logged in. If the errorCode == 401 then a logout must follow. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). Fields that can be changed:
- setFirstName, setLastName, setEmail, setSalutation, setMsisdn, setNickname, setGender, setBirthDate, setNameday, setTaxId
- setOptin -> If we want to change the communications (i.e info via newsletter or sms or both, same for personalized), if true then we set the below fields (all are boolean): setNewsletter, setSms, setPersonalizedNewsletter, setPersonalizedSms
- setHasProfileMetadata -> If we want to save custom info on consumer. If true then we set also the below field as a json object: setProfileMetadata
- Note: We only use the fields we want to change. WarplyManager.editConsumer(new WarplyEditConsumerRequest() .setFirstName("test") .setLastName("test"), mEditConsumerReceiver);
private CallbackReceiver mEditConsumerReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Change User Photo
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The setUserId method must be the consumer.uuid, we can find it in Consumer object from (11 : User Profile request). The setImageBase64 method must be the base64 string of the image we want to upload. WarplyManager.uploadConsumerPhoto(new WarplyUploadConsumerPhotoRequest() .setUserId("") .setImageBase64(""), mUploadConsumerPhotoReceiver);
private CallbackReceiver mUploadConsumerPhotoReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Add Card
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 4 then the card is already added. WarplyManager.addCard(new WarplyAddCardRequest() .setCardIssuer("Visa") .setCardNumber("1234567812345678") .setCardHolder("test test") .setCardExpMonth("01") .setCardExpYear("2026"), mAddCardReceiver);
private CallbackReceiver mAddCardReceiver = new CallbackReceiver() { @Override public void onSuccess(Card result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Get Cards
We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getCards(new WarplyGetCardsRequest(), mGetCardsReceiver);
private CallbackReceiver mGetCardsReceiver = new CallbackReceiver() { @Override public void onSuccess(CardList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Delete Card
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. WarplyManager.deleteCard(new WarplyDeleteCardRequest() .setCardToken("af993aead7d24abfbac716c276d8c6f5"), mDeleteCardReceiver);
private CallbackReceiver mDeleteCardReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Verify Ticket
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). WarplyManager.verifyTicket(new WarplyVerifyTicketRequest() .setGuid("") .setTicket(""), mVerifyTicketReceiver);
private CallbackReceiver mVerifyTicketReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- User Coupons
We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
private CallbackReceiver mUserCouponsReceiver = new CallbackReceiver() { @Override public void onSuccess(CouponList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Transactions History
We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getTransactionHistory(new WarplyTransactionHistoryRequest(), mTransactionHistoryReceiver);
private CallbackReceiver mTransactionHistoryReceiver = new CallbackReceiver() { @Override public void onSuccess(TransactionsList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Points History
We have to be logged in. If the errorCode == 401 then a logout must follow. There is a relation between this and the (21 : Transactions History request). WarplyManager.getPointHistory(new WarplyPointHistoryRequest(), mPointHistoryReceiver);
private CallbackReceiver mPointHistoryReceiver = new CallbackReceiver() { @Override public void onSuccess(PointsList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Add Address
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. WarplyManager.addAddress(new WarplyAddAddressRequest() .setFriendlyName("panos") .setAddressName("moustaka 4") .setAddressNumber("4") .setPostalCode("32200") .setFloorNumber(1) .setDoorbell("triant") .setRegion("thiva") .setNotes("tel"), mAddAddressReceiver);
private CallbackReceiver mAddAddressReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Get Addresses
We have to be logged in. If the errorCode == 401 then a logout must follow. WarplyManager.getAddressList(new WarplyGetAddressRequest(), mGetAddressReceiver);
private CallbackReceiver mGetAddressReceiver = new CallbackReceiver() { @Override public void onSuccess(AddressList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Edit Address
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. The fields are the same like the (24 : Add Address request). In addition to the other fields we must fill the uuid of the address we want to edit.
- Note: We only use the fields we want to change. WarplyManager.editAddress(new WarplyEditAddressRequest() .setUuid("5f83af68ebc34e94b1ffd9143772bda1") .setAddressName("moustaka 2"), mEditAddressReceiver);
private CallbackReceiver mEditAddressReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Delete Address
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. We must fill the uuid of the address we want to delete. WarplyManager.deleteAddress(new WarplyDeleteAddressRequest() .setUuid("5f83af68ebc34e94b1ffd9143772bda1"), mDeleteAddressReceiver);
private CallbackReceiver mDeleteAddressReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Redeem Product
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If the errorCode == 401 then a logout must follow. WarplyManager.redeemProduct(new WarplyRedeemCouponRequest() .setSku("") .setUuid(""), mRedeemCouponReceiver);
private CallbackReceiver mRedeemCouponReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Forgot Password
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The setId field must be one of email or msisdn.
- Note: If the setId field is email then we first make the (28 : Forgot Password request) and then the (29 : Reset Password request).
- Note: If the setId field is msisdn then we first make the (30 : Request OTP request) and then the (29 : Reset Password request) without the need of the (28 : Forgot Password request). WarplyManager.forgotPassword(new WarplyForgotPasswordRequest() .setId("") mForgotPasswordReceiver);
private CallbackReceiver mForgotPasswordReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Reset Password
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also).
- If (28 : setId) is email then we only use the setPassword and setConfToken methods.
- The setConfToken value is included as a parameter to the deeplink that we are redirected from the info email.
- If (28 : setId) is msisdn then we only the setOtp and setOtpUuid methods with values from (30 : Request OTP request). WarplyManager.resetPassword(new WarplyResetPasswordRequest() .setPassword("") .setConfToken("") .setOtp("") .setOtpUuid(""), mResetPasswordReceiver);
private CallbackReceiver mResetPasswordReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Request OTP
From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). The setScope must be one of reset, edit or verify. WarplyManager.requestOTP(new WarplyRequestOTPRequest() .setMsisdn("") .setScope(""), mRequestOTPReceiver);
private CallbackReceiver mRequestOTPReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Merchants Multilingual
We can request the merchants in multilingual way.
- The setIsMultilingual method must be true.
- The setLanguage method is used to search on the language we provide.
- The setCategories method is used if we want to filter by category/ies. It’s a list of categories uuid.
- The setTags method is used if we want to filter with keywords. It’s a list of tags uuid (7 : Tags request).
- The setMerchantUuid method is used to search for a specific merchant. We need to add the uuid of that merchant.
- The setCenter and setDistance are used to filter by location. WarplyManager.getMerchantsMultilingual(new WarplyMerchantsRequest() .setIsMultilingual(true) .setCategories(cat) .setTags(tag), mMerchantsMultilingualReceiver);
private CallbackReceiver mMerchantsMultilingualReceiver = new CallbackReceiver() { @Override public void onSuccess(MerchantList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Get User Couponsets
- The setLanguage method is used to get the user couponsets to the language that are configured on the engage platform.
- The setUuids method is used to get specific couponsets, if we know the coupon_uuid of them. It’s a list of string uuid. WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest() .setLanguage("el") mCouponsetsReceiver);
private CallbackReceiver mCouponsetsReceiver = new CallbackReceiver() { @Override public void onSuccess(CouponsetsList result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Redeem Coupon
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). Additionally the response includes a result key (json) that includes the coupon and it’s expiration date, if any. If the errorCode == 401 then a logout must follow.
- The setCouponsetUuid method is used to get a coupon from the given couponset. WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest() .setCouponsetUuid("7de77a1731d44a95a74a653f8e823fa4"), mRedeemCouponReceiver);
private CallbackReceiver mRedeemCouponReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};
- Validate Coupon
We have to be logged in. From the response json we check if status == 1 that means success, everything else means an error (like in onFailure also). If status == 1, from result key, we have to check which items are satisfied == true. Only then is truly success. If the above case has no satisfied == true then we check the failed key that includes the different error messages in the msg key. If status == 4 means that no rule has been satisfied. If the errorCode == 401 then a logout must follow.
- The setCoupon method is used to check the given coupon code we retrieved from (33 : Redeem Coupon request). WarplyManager.validateCoupon(new WarplyValidateCouponRequest() .setCoupon("CBGEJEYC"), mValidateCouponReceiver);
private CallbackReceiver mValidateCouponReceiver = new CallbackReceiver() { @Override public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
}
};