bmob-android-demo-push | 比目android端推送SDK演示案例。

 by   bmob Java Updated: 2 years ago - Current License: No License

Download this library from

Build Applications

kandi X-RAY | bmob-android-demo-push REVIEW AND RATINGS

比目android端推送SDK演示案例。

kandi-support
Support

  • bmob-android-demo-push has a low active ecosystem.
  • It has 20 star(s) with 9 fork(s).
  • It had no major release in the last 12 months.
  • It has a neutral sentiment in the developer community.

quality kandi
Quality

  • bmob-android-demo-push has no issues reported.

security
Security

  • bmob-android-demo-push has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

license
License

  • bmob-android-demo-push does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.

build
Reuse

  • bmob-android-demo-push releases are not available. You will need to build from source code and install.
  • bmob-android-demo-push has no build file. You will be need to create the build yourself to build the component from source.
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

bmob-android-demo-push Key Features

比目android端推送SDK演示案例。

bmob-android-demo-push examples and code snippets

  • 2.1、集成SDK
  • 2.2、配置AndroidManifest.xml
  • 2.3、配置代码
  • 3.3、推送注意事项
  • 4.1、初始化设备信息
  • 4.2、自定义Installation表
  • 4.3.1、订阅频道
  • 4.3.2、退订频道
  • 4.3.3、获取已经订阅的频道
  • 4.4、客户端广播推送消息
  • 4.5、客户端组播推送消息
  • 4.6.1、根据平台做推送
  • 4.6.2、根据地理位置信息推送
  • 4.6.3、推送消息给不活跃的设备
  • 4.6.4、根据查询条件做推送
  • 4.7、客户端点播推送消息

2.1、集成SDK

allprojects {
    repositories {
        jcenter()
        //Bmob的maven仓库地址
        maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" }
    }
}

2.2、配置AndroidManifest.xml

    <!--TODO 集成:1.1、添加数据SDK和推送SDK需要的权限-->
    <!--比目数据SDK所需的权限-->
    <!--允许联网 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!--获取GSM(2g)、WCDMA(联通3g)等网络状态的信息  -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!--获取wifi网络状态的信息 -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!--保持CPU 运转,屏幕和键盘灯有可能是关闭的,用于文件上传和下载 -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!--获取sd卡写的权限,用于文件上传和下载-->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!--允许读取手机状态 用于创建BmobInstallation-->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />


    <!--推送所需的权限-->
    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

2.3、配置代码

//TODO 集成:1.3、创建自定义的推送消息接收器,并在清单文件中注册
public class MyPushMessageReceiver extends BroadcastReceiver{

	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		if(intent.getAction().equals(PushConstants.ACTION_MESSAGE)){
			Log.d("bmob", "客户端收到推送内容:"+intent.getStringExtra("msg"));
		}
	}
	
}

3.3、推送注意事项

{
	"aps": {
	"sound": "cheering.caf", 
	"alert": "这个是通知栏上显示的内容", 
	"badge": 0 
	}, 
	"xx" : "json的key-value对,你可以根据情况添加更多的,客户端进行解析获取", 
}

4.1、初始化设备信息

BmobInstallationManager.getInstance().initialize(new InstallationListener<BmobInstallation>() {
            @Override
            public void done(BmobInstallation bmobInstallation, BmobException e) {
                if (e == null) {
                    Logger.i(bmobInstallation.getObjectId() + "-" + bmobInstallation.getInstallationId());
                } else {
                    Logger.e(e.getMessage());
                }
            }
        });

4.2、自定义Installation表

public class Installation extends BmobInstallation {

    private User user;
    private BmobGeoPoint location;


    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public BmobGeoPoint getLocation() {
        return location;
    }

    public void setLocation(BmobGeoPoint location) {
        this.location = location;
    }
}

4.3.1、订阅频道

BmobInstallationManager.getInstance().subscribe(Arrays.asList("NBA", "CBA", "IJK", "NBA", "CBA", "USA"), new InstallationListener<BmobInstallation>() {
                    @Override
                    public void done(BmobInstallation bmobInstallation, BmobException e) {
                        if (e == null) {
                            toastI("批量订阅成功");
                        } else {
                            toastE(e.getMessage());
                        }
                    }
                });

4.3.2、退订频道

BmobInstallationManager.getInstance().unsubscribe(Arrays.asList("CBA", "USA"), new InstallationListener<BmobInstallation>() {
                    @Override
                    public void done(BmobInstallation bmobInstallation, BmobException e) {
                        if (e == null) {
                            toastI("批量取消订阅成功");
                        } else {
                            toastE(e.getMessage());
                        }
                    }
                });

4.3.3、获取已经订阅的频道

BmobInstallation bmobInstallation = BmobInstallationManager.getInstance().getCurrentInstallation();
                List<String> channels = bmobInstallation.getChannels();
                if (channels.size() < 1) {
                    toastI("您没有订阅任何频道!");
                } else {
                    for (String channel : channels) {
                        mTvChannel.append(channel + "\n");
                    }
                }

4.4、客户端广播推送消息

    BmobPushManager bmobPushManager = new BmobPushManager();
    bmobPushManager.pushMessageAll("消息内容", new PushListener() {
        @Override
        public void done(BmobException e) {
            if (e==null){
                Logger.e("推送成功!");
            }else {
                Logger.e("异常:" + e.getMessage());
            }
        }
    });

4.5、客户端组播推送消息

                BmobPushManager bmobPushManager = new BmobPushManager();
                BmobQuery<BmobInstallation> query = BmobInstallation.getQuery();
                List<String> channels = new ArrayList<>();
                //TODO 替换成你需要推送的所有频道,推送前请确认已有设备订阅了该频道,也就是channels属性存在该值
                channels.add("NBA");
                query.addWhereContainedIn("channels", channels);
                bmobPushManager.setQuery(query);
                bmobPushManager.pushMessage("消息内容", new PushListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Logger.e("推送成功!");
                        } else {
                            Logger.e("异常:" + e.getMessage());
                        }
                    }
                });

4.6.1、根据平台做推送

                BmobPushManager bmobPushManager = new BmobPushManager();
                BmobQuery<BmobInstallation> query = BmobInstallation.getQuery();
                //TODO 属性值为android
                query.addWhereEqualTo("deviceType", "android");
                bmobPushManager.setQuery(query);
                bmobPushManager.pushMessage("消息内容", new PushListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Logger.e("推送成功!");
                        } else {
                            Logger.e("异常:" + e.getMessage());
                        }
                    }
                });

4.6.2、根据地理位置信息推送

                BmobPushManager bmobPushManager = new BmobPushManager();
                BmobQuery<BmobInstallation> query = BmobInstallation.getQuery();
                //TODO 替换你需要推送的地理位置的经纬度和范围,发送前请确认installation表中已有location的BmobGeoPoint类型属性
                query.addWhereWithinRadians("location", new BmobGeoPoint(113.385610000, 23.0561000000), 1.0);
                bmobPushManager.setQuery(query);
                bmobPushManager.pushMessage("消息内容", new PushListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Logger.e("推送成功!");
                        } else {
                            Logger.e("发送前请确认installation表中已有location的BmobGeoPoint类型属性");
                            Logger.e("异常:" + e.getMessage());
                        }
                    }
                });

4.6.3、推送消息给不活跃的设备

                BmobPushManager bmobPushManager = new BmobPushManager();
                BmobQuery<BmobInstallation> query = BmobInstallation.getQuery();
                //TODO 替换你需要的判断为不活跃的时间点
                query.addWhereLessThan("updatedAt", new BmobDate(new Date()));
                bmobPushManager.setQuery(query);
                bmobPushManager.pushMessage("消息内容", new PushListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Logger.e("推送成功!");
                        } else {
                            Logger.e("异常:" + e.getMessage());
                        }
                    }
                });

4.6.4、根据查询条件做推送

               //TODO 替换成你作为判断需要推送的属性名和属性值,推送前请确认installation表已有该属性
                query.addWhereEqualTo("替换成你作为判断需要推送的属性名", "替换成你作为判断需要推送的属性值");
                bmobPushManager.setQuery(query);
                bmobPushManager.pushMessage("消息内容", new PushListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Logger.e("推送成功!");
                        } else {
                            Logger.e("异常:" + e.getMessage());
                        }
                    }
                });

4.7、客户端点播推送消息

                //TODO 替换成所需要推送的Android客户端installationId
                BmobPushManager bmobPushManager = new BmobPushManager();
                BmobQuery<BmobInstallation> query = BmobInstallation.getQuery();
                String installationId = "【替换你需要的id】其他Android客户端installationId";
                query.addWhereEqualTo("installationId", installationId);
                bmobPushManager.setQuery(query);
                bmobPushManager.pushMessage("消息内容", new PushListener() {
                    @Override
                    public void done(BmobException e) {
                        if (e == null) {
                            Logger.e("推送成功!");
                        } else {
                            Logger.e("异常:" + e.getMessage());
                        }
                    }
                });

COMMUNITY DISCUSSIONS

No Community Discussions are available at this moment for bmob-android-demo-push.Refer to stack overflow page for discussions.

No Community Discussions are available at this moment for bmob-android-demo-push.Refer to stack overflow page for discussions.

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

VULNERABILITIES

No vulnerabilities reported

INSTALL bmob-android-demo-push

You can use bmob-android-demo-push like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the bmob-android-demo-push component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

SUPPORT

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Implement bmob-android-demo-push faster with kandi.

  • Use the support, quality, security, license, reuse scores and reviewed functions to confirm the fit for your project.
  • Use the, Q & A, Installation and Support guides to implement faster.

Discover Millions of Libraries and
Pre-built Use Cases on kandi