Skip to content

Commit

Permalink
Version_0.2.5-fix2
Browse files Browse the repository at this point in the history
  • Loading branch information
censujiang committed Nov 2, 2023
1 parent 0ffa1f1 commit d9651ff
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
20 changes: 18 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* @uni-helper/galanga 0.2.5-fix1 (https://github.com/uni-helper/galanga)
* @uni-helper/galanga 0.2.5-fix2 (https://github.com/uni-helper/galanga)
* API https://galanga.censujiang.com/api/
* Copyright 2014-2023 censujiang. All Rights Reserved
* Licensed under Apache License 2.0 (https://github.com/uni-helper/galanga/blob/master/LICENSE)
Expand Down Expand Up @@ -975,7 +975,23 @@ const notificationPermission = {
plus.ios.deleteObject(UIApplication);
}
else {
result = await requestAndroidPermission('android.permission.ACCESS_NOTIFICATION_POLICY');
//首先判断安卓13引入的新权限
result = await requestAndroidPermission('android.permission.POST_NOTIFICATIONS');
//不运行的时候不通知?没关系,我们再试试旧的权限,反正我们只需要知道应用到底能不能发起通知
if (result == false) {
const main = plus.android.runtimeMainActivity();
let NotificationManagerCompat = plus.android.importClass("android.support.v4.app.NotificationManagerCompat");
if (checkNull(NotificationManagerCompat)) {
NotificationManagerCompat = plus.android.importClass("androidx.core.app.NotificationManagerCompat");
}
const notificationManagerResult = NotificationManagerCompat.from(main).areNotificationsEnabled();
if (!notificationManagerResult) {
result = false;
}
else {
result = true;
}
}
}
// #endif
// #ifndef H5 || APP-PLUS
Expand Down
38 changes: 27 additions & 11 deletions esm/permission.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as origin from 'galanga';
import { checkNull, notificationPermission as notificationPermissionO, clipboardPermission as clipboardPermissionO, locationPermission as locationPermissionO } from 'galanga';
// #ifdef APP-PLUS
const isIOS = (plus.os.name == "iOS");
// #endif
Expand All @@ -7,7 +7,7 @@ export const notificationPermission = {
check: async () => {
let result;
// #ifdef H5
result = await origin.notificationPermission.check();
result = await notificationPermissionO.check();
// #endif
// #ifdef MP || QUICKAPP-WEBVIEW
result = await uni.getSetting().then((res) => {
Expand Down Expand Up @@ -59,7 +59,7 @@ export const notificationPermission = {
request: async () => {
let result;
// #ifdef H5
result = await origin.notificationPermission.request();
result = await notificationPermissionO.request();
// #endif
// #ifdef APP-PLUS
if (isIOS === true) {
Expand Down Expand Up @@ -91,13 +91,29 @@ export const notificationPermission = {
plus.ios.deleteObject(UIApplication);
}
else {
result = await requestAndroidPermission('android.permission.ACCESS_NOTIFICATION_POLICY');
//首先判断安卓13引入的新权限
result = await requestAndroidPermission('android.permission.POST_NOTIFICATIONS');
//不运行的时候不通知?没关系,我们再试试旧的权限,反正我们只需要知道应用到底能不能发起通知
if (result == false) {
const main = plus.android.runtimeMainActivity();
let NotificationManagerCompat = plus.android.importClass("android.support.v4.app.NotificationManagerCompat");
if (checkNull(NotificationManagerCompat)) {
NotificationManagerCompat = plus.android.importClass("androidx.core.app.NotificationManagerCompat");
}
const notificationManagerResult = NotificationManagerCompat.from(main).areNotificationsEnabled();
if (!notificationManagerResult) {
result = false;
}
else {
result = true;
}
}
}
// #endif
// #ifndef H5 || APP-PLUS
//小程序暂时没有思路去请求,暂时只做检查
result = await notificationPermission.check().then((check) => {
if (origin.checkNull(check)) {
if (checkNull(check)) {
return false;
}
return check;
Expand All @@ -113,7 +129,7 @@ export const clipboardPermission = {
check: async () => {
let result;
// #ifdef H5
result = await origin.clipboardPermission.check();
result = await clipboardPermissionO.check();
// #endif
// #ifndef H5
result = await uni.getClipboardData().then(() => {
Expand All @@ -127,11 +143,11 @@ export const clipboardPermission = {
request: async () => {
let result;
// #ifdef H5
result = await origin.clipboardPermission.request();
result = await clipboardPermissionO.request();
// #endif
// #ifndef H5
result = await clipboardPermission.check().then((check) => {
if (origin.checkNull(check)) {
if (checkNull(check)) {
return false;
}
return check;
Expand All @@ -147,7 +163,7 @@ export const locationPermission = {
check: async () => {
let result;
// #ifdef H5
result = await origin.locationPermission.check();
result = await locationPermissionO.check();
// #endif
// #ifdef APP-PLUS
if (isIOS === true) {
Expand All @@ -172,11 +188,11 @@ export const locationPermission = {
request: async () => {
let result;
// #ifdef H5
result = await origin.locationPermission.request();
result = await locationPermissionO.request();
// #endif
// #ifdef MP || QUICKAPP-WEBVIEW
result = await locationPermission.check().then((check) => {
if (origin.checkNull(check)) {
if (checkNull(check)) {
return false;
}
return check;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uni-helper/galanga",
"version": "0.2.5-fix1",
"version": "0.2.5-fix2",
"description": "JS common function library(UNI-APP version of Galanga)",
"main": "esm/index.js",
"jsnext:main": "esm/index.js",
Expand Down

0 comments on commit d9651ff

Please sign in to comment.