iApp检查与获取推送权限
大家好我是抹茶今天给大家带来iApp“iApp检查与获取推送权限”的教程,希望对大家有用!
iApp获取当前应用是否有推送权限
javags(APP_OPS_SERVICE,null,"android.content.Context.APP_OPS_SERVICE")
java(aom,activity,"android.app.Activity.getSystemService","String",APP_OPS_SERVICE)
java(appinfo,activity,"android.content.ContextWrapper.getApplicationInfo")
javags(uid,appinfo,"android.content.pm.ApplicationInfo.uid")
java(appcontext,activity,"android.content.ContextWrapper.getApplicationContext")
java(pkg,appcontext,"android.content.Context.getPackageName")
javags(field,null,"android.app.AppOpsManager","OP_POST_NOTIFICATION")
java(method,aom,"android.app.AppOpsManager.checkOpNoThrow","int",field,"int",uid,"String",pkg)
javags(MODE_ALLOWED,null,"android.app.AppOpsManager","MODE_ALLOWED")
iApp检查与获取推送权限获取完推送权限后我们接下来判断是否有推送权限。
判断推送权限并发送到通知栏
f(method==MODE_ALLOWED){
java(nm,activity,"android.app.Activity.getSystemService","String","notification")
javanew(nb,"android.app.Notification$Builder","Context",activity)
java(null,nb,"android.app.Notification$Builder.setSmallIcon","int",17301543)
//设置图标
java(null,nb,"android.app.Notification$Builder.setTicker","java.lang.CharSequence","新通知")
//提示内容
java(null,nb,"android.app.Notification$Builder.setDefaults","int",-1)
//发送推送时震动
java(null,nb,"android.app.Notification$Builder.setContentTitle","java.lang.CharSequence","标题")
//标题
java(null,nb,"android.app.Notification$Builder.setContentText","java.lang.CharSequence","内容233")
//内容
java(null,nb,"android.app.Notification$Builder.setAutoCancel","boolean",true)
java(nft,nb,"android.app.Notification$Builder.build")
java(null,nm,"android.app.NotificationManager.notify","int",1,"android.app.Notification",nft)
//推送到通知栏,并且不执行下面代码
endcode
}
可以发送到通知栏的效果:
iApp检查与获取推送权限打开获取权限窗口
utw(null,"提示","发现程序无法推送通知栏了,想要最新资讯点击开启权限哟!","开启权限","取消",true,v){
javags(SDK_INT,activity,"android.os.Build$VERSION","SDK_INT")
javanew(intent,"android.content.Intent")
f(SDK_INT>=26){
java(null,intent,"android.content.Intent.setAction","String","android.settings.APP_NOTIFICATION_SETTINGS")
java(null,intent,"android.content.Intent.putExtra","String","android.provider.extra.APP_PACKAGE","String",pkg)
}else f(SDK_INT>=21){
java(null,intent,"android.content.Intent.setAction","String","android.settings.APP_NOTIFICATION_SETTINGS")
java(null,intent,"android.content.Intent.putExtra","String","app_package","String",pkg)
java(null,intent,"android.content.Intent.putExtra","String","app_uid","int",uid)
}else{
java(null,intent,"android.content.Intent.setAction","String","android.settings.APP_NOTIFICATION_SETTINGS")
java(uri,null,"android.net.Uri.fromParts","String","package","String",pkg,"String",null)
java(null,intent,"android.content.Intent.setData","android.net.Uri",uri)
}
java(null,intent,"android.content.Intent.setFlags","int",268435456)
java(null,activity,"android.app.Activity.startActivity","android.content.Intent",intent)
}else{
}
//欢迎加入二次元iApp交流群:454141930
没有获取到权限后的跳转效果:
iApp检查与获取推送权限