Git Product home page Git Product logo

payment-listener's Introduction

payment-monitor

payment-monitor 是一款Android原生插件,对手机通知栏监听,针对支付类型通知进行回调.

目前支持

  • 支付宝
  • 收钱吧
  • 工商银行
  • 云闪付
  • 微信 / 微信店员

0.0.3

这里更新了文档为uni的引入方式,历史版本写的是weex引入方法可能有所误导.

<script>
	// 云端插件依赖后,代码引入
	const notifyListenerPlugin = uni.requireNativePlugin('lhalcyon-payment-monitor');

	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		methods: {
		  // 测试调用Android原生toast
			onToast(){
				notifyListenerPlugin.show('heheda');
			},
			// 获取是否有通知栏权限
			getNotification(){
				const isEnable = notifyListenerPlugin.isNotificationListening();
				notifyListenerPlugin.show('通知栏权限是否开启:'+isEnable);
			},
			// 跳转原生通知栏设置页, 需要Android >=5.1
			onJumpToSettings(){
				notifyListenerPlugin.jumpToNotificationSettingPage();
			},
			// 初始化通知监听服务,并设置监听回调
      // params 是string的map  ,主要key有 type,time,title,money,content,transferor 等
      // 具体可以参考 https://github.com/lhalcyon/payment-listener/tree/master/payment-listener/src/main/java/com/lhalcyon/pl/handler 查看各通知类型具体字段
			initNotificationCallback(){
				notifyListenerPlugin.show('init invoked');
				notifyListenerPlugin.initNotificationCallback(function (params) {
				    notifyListenerPlugin.show('notification callback:'+params);
				});
			},
      // 这里是将服务前台化,方便用户感知监听,以及提升服务存活性,但是需要 Android O及以上版本才能使用,否则和 startService() 方法一样处理
			startForegroundService(){
				notifyListenerPlugin.show('startForegroundService');
        // 这里的两个参数分别为通知栏的标题和描述
				notifyListenerPlugin.startForegroundService('plugin test title','working in the foreground');
			},
      // 停止这里调用 stopService() 是一样的效果
			stopForegroundService(){
				notifyListenerPlugin.show('stopForegroundService');
				notifyListenerPlugin.stopForegroundService();
			},
		}
	}
</script>

前台服务演示:

回调中的params字段实例:


payment-listener's People

Contributors

lhalcyon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.