Skip to content

Commit

Permalink
2.4.1 update
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdi-malv committed Jan 2, 2021
1 parent 13d7cab commit 50cfb1a
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 53 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Simple implementation of [Pushe](http://pushe.co) SDK using Android studio and J

```groovy
dependencies {
implementation 'co.pushe.plus:base:2.4.0'
implementation 'co.pushe.plus:base:2.4.1' // Core module + essential
implementation 'co.pushe.plus:hms:2.4.1' // Huawei PushKit support
implementation 'co.pushe.plus:inappmessaging:2.4.1' // InAppMessaging
}
```

Expand Down
15 changes: 8 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"

defaultConfig {

// This is the application id (which must be the package name you add into panel of Pushe)
applicationId "co.ronash.pushesample.as"
applicationId "co.pushe.sample.as"
minSdkVersion 17
targetSdkVersion 30
versionCode 16 // Mmp
versionName '0.1.6'
versionCode 17
multiDexEnabled true

versionName pusheVersion
Expand All @@ -33,18 +32,20 @@ dependencies {
implementation 'androidx.multidex:multidex:2.0.1'

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.media:media:1.2.0'
implementation 'androidx.media:media:1.2.1'

// ButterKnife: To easily connect XML to code
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

// Event bus: To send event through application from anywhere to anywhere
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'org.greenrobot:eventbus:3.2.0'

implementation "co.pushe.plus:base:$pusheVersion"
implementation "co.pushe.plus:hms:$pusheVersion"
implementation "co.pushe.plus:inappmessaging:$pusheVersion"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-messaging:21.0.0'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
}
25 changes: 10 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="co.ronash.pushesample.as">
package="co.pushe.sample.as">

<uses-permission android:name="co.ronash.pushesample.as.permission.C2D_MESSAGE" />
<uses-permission android:name="co.pushe.sample.as.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
Expand All @@ -24,28 +24,23 @@
</intent-filter>
</activity>

<!-- &lt;!&ndash; Notification click/dismiss receiver &ndash;&gt;-->
<!-- <receiver android:name=".receiver.NotificationClickDismissReceiver">-->
<!-- <intent-filter>-->
<!-- <action android:name="co.ronash.pushesample.as.pusheco.NOTIF_CLICKED"/>-->
<!-- <action android:name="co.ronash.pushesample.as.pusheco.NOTIF_DISMISSED" />-->
<!-- <action android:name="co.ronash.pushesample.as.pusheco.NOTIF_BTN_CLICKED" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->


<!-- Credential belongs to Pushe demo console. check `pushe.co` -->
<meta-data
android:name="pushe_token"
android:value="cWQyM2p3eXJ3NzZsdm81ZUBlaXpAMTM0NTExMDA3MTA5" />
android:value="MmV5bTN6b3ZtMmtwODcxZUBxcW1AMjY1ODgxNzI4NTQ3" />

<meta-data
android:name="pushe_log_level"
android:value="debug" />

<!-- Custom firebase service for Pushe -->

<service
android:name="co.pushe.plus.messaging.fcm.FcmService"
android:name="co.pushe.plus.fcm.FcmService"
tools:node="remove" />

<service android:name=".services.MyFcmService">
<service android:name=".services.MyFcmService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.ronash.pushesample.as.activities;
package co.pushe.sample.as.activities;

import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
Expand Down Expand Up @@ -38,20 +38,21 @@
import co.pushe.plus.notification.PusheNotification;
import co.pushe.plus.notification.PusheNotificationListener;
import co.pushe.plus.notification.UserNotification;
import co.ronash.pushesample.as.R;
import co.ronash.pushesample.as.eventbus.MessageEvent;
import co.ronash.pushesample.as.utils.Stuff;
import co.pushe.sample.as.R;
import co.pushe.sample.as.eventbus.MessageEvent;
import co.pushe.sample.as.utils.Stuff;

import static co.ronash.pushesample.as.utils.Stuff.addText;
import static co.ronash.pushesample.as.utils.Stuff.alert;
import static co.ronash.pushesample.as.utils.Stuff.prompt;
import static co.pushe.sample.as.utils.Stuff.addText;
import static co.pushe.sample.as.utils.Stuff.alert;
import static co.pushe.sample.as.utils.Stuff.prompt;

/**
* For further information Go to <a href="https://pushe.co/docs">Docs</a>
*
* @author Mahdi Malvandi
*/
@SuppressLint("SetTextI18n")
@SuppressWarnings({"rawtypes", "unchecked", "unused", "RedundantSuppression"})
@SuppressLint("SetTextI18n,NonConstantResourceId")
public class MainActivity extends AppCompatActivity {

private PusheInAppMessaging inAppMessaging;
Expand Down Expand Up @@ -197,7 +198,7 @@ private ItemClickListener handleItemClick() {
public void onItemClick(View v, int position) {
switch (position) {
case 0:
alert(MainActivity.this, "IDs", "AndroidId:\n" + Pushe.getAndroidId() + "\nGoogleAdId:\n" + Pushe.getGoogleAdvertisingId());
alert(MainActivity.this, "IDs", "AndroidId:\n" + Pushe.getDeviceId() + "\nGoogleAdId:\n" + Pushe.getAdvertisingId());
break;
case 1:
prompt(MainActivity.this, "New custom id", "current custom id:" + Pushe.getCustomId(), new Consumer<String>() {
Expand Down Expand Up @@ -262,7 +263,7 @@ public void onPositiveButtonClicked(String s) {
Map map = new HashMap();
map.put(keyValue[0], keyValue[1]);
Pushe.addTags(map);
addText(scroll, status, "Tag \'" + keyValue[0] + "\' added ");
addText(scroll, status, "Tag '" + keyValue[0] + "' added ");
}

@Override
Expand Down Expand Up @@ -318,7 +319,7 @@ public void onPositiveButtonClicked(String s) {

@Override
public void onNegativeButtonClicked(String s) {
UserNotification userNotification = UserNotification.withAndroidId(Pushe.getAndroidId());
UserNotification userNotification = UserNotification.withAndroidId(Pushe.getDeviceId());
userNotification.setTitle("title1");
userNotification.setContent("content1");
Pushe.getPusheService(PusheNotification.class).sendNotificationToUser(userNotification);
Expand All @@ -341,7 +342,7 @@ public void onPositiveButtonClicked(String s) {

@Override
public void onNegativeButtonClicked(String s) {
UserNotification userNotification = UserNotification.withAdvertisementId(Pushe.getGoogleAdvertisingId());
UserNotification userNotification = UserNotification.withAdvertisementId(Pushe.getAdvertisingId());
userNotification.setTitle("title1");
userNotification.setContent("content1");
Pushe.getPusheService(PusheNotification.class).sendNotificationToUser(userNotification);
Expand Down Expand Up @@ -417,10 +418,10 @@ protected void onStop() {
// region List

// List adapter
class Adapter extends RecyclerView.Adapter<Holder> {
static class Adapter extends RecyclerView.Adapter<Holder> {

private List<String> dataSet;
private ItemClickListener listener;
private final List<String> dataSet;
private final ItemClickListener listener;

Adapter(List<String> dataSet, ItemClickListener listener) {
this.dataSet = dataSet;
Expand Down Expand Up @@ -452,7 +453,7 @@ public int getItemCount() {
}

// List view holder
class Holder extends RecyclerView.ViewHolder {
static class Holder extends RecyclerView.ViewHolder {

@BindView(R.id.text)
TextView action;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.ronash.pushesample.as.eventbus;
package co.pushe.sample.as.eventbus;


/**
Expand All @@ -7,7 +7,7 @@
*/
public class MessageEvent {

private String message;
private final String message;

public String getMessage() {
return message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.ronash.pushesample.as.services;
package co.pushe.sample.as.services;



Expand All @@ -14,12 +14,13 @@

public class MyFcmService extends FirebaseMessagingService {

private FcmHandler fcmHandler = Pushe.getPusheService(PusheFCM.class).getFcmHandler();
private final FcmHandler fcmHandler = Pushe.getPusheService(PusheFCM.class).getFcmHandler();

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {

Log.d("P_AS", "Message received: \n" + remoteMessage.getData());
if (fcmHandler.onMessageReceived(remoteMessage)) {
if (fcmHandler != null && fcmHandler.onMessageReceived(remoteMessage)) {
// Message is for Pushe
return;
}
Expand All @@ -30,31 +31,39 @@ public void onMessageReceived(RemoteMessage remoteMessage) {

@Override
public void onNewToken(String s) {
fcmHandler.onNewToken(s);
if (fcmHandler != null) {
fcmHandler.onNewToken(s);
}
super.onNewToken(s);

// Token is refreshed
}

@Override
public void onMessageSent(String s) {
fcmHandler.onMessageSent(s);
if (fcmHandler != null) {
fcmHandler.onMessageSent(s);
}
super.onMessageSent(s);

// Message sent
}

@Override
public void onDeletedMessages() {
fcmHandler.onDeletedMessages();
if (fcmHandler != null) {
fcmHandler.onDeletedMessages();
}
super.onDeletedMessages();

// Message was deleted
}

@Override
public void onSendError(String s, Exception e) {
fcmHandler.onSendError(s, e);
if (fcmHandler != null) {
fcmHandler.onSendError(s, e);
}
super.onSendError(s, e);

// Error sent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.ronash.pushesample.as.utils;
package co.pushe.sample.as.utils;

import android.content.Context;
import android.content.DialogInterface;
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ buildscript {
* Refer to Pushe release note for more information about versions
* https://docs.pushe.co/docs/android-studio/releasenote
*/
pusheVersion = '2.4.0'
pusheVersion = '2.4.1'
}

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.1.1'
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Nov 10 18:03:35 IRST 2020
#Sat Jan 02 12:20:18 IRST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

0 comments on commit 50cfb1a

Please sign in to comment.