leon 1 年之前
父节点
当前提交
4a3f73d423

文件差异内容过多而无法显示
+ 0 - 0
android/app/src/main/assets/index.android.bundle


文件差异内容过多而无法显示
+ 0 - 0
android/app/src/main/assets/index.android.map


+ 16 - 9
android/app/src/main/java/com/hola/HolaModule.java

@@ -46,12 +46,6 @@ import java.util.Calendar;
 import java.util.List;
 
 public class HolaModule extends ReactContextBaseJavaModule {
-    private static final String CHANNEL_ID = "REMINDER_FS";
-    private static final String CHANNEL_NAME = "Reminders for Fasting and Sleep";
-
-    private static final String CHANNEL_ID_ADDITIONAL = "REMINDER_FS_ADDITIONAL";
-    private static final String CHANNEL_NAME_ADDITIONAL = "Extra Reminders for Fasting and Sleep";
-    private static final String CHANNEL_NAME_SUNRISE = "REMINDER_SUN";
     private static final String CHANNEL_DESCRIPTION = "Daily reminder notification ";
 
     private Location gpsLocation;
@@ -188,9 +182,10 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 String title = jsonObject.getString("title");
                 String body = jsonObject.getString("body");
                 String strId = jsonObject.getString("id");
+                String channelId = jsonObject.getString("channel_id");
                 String categoryId = jsonObject.getString("category_id");
 
-                createNotificationChannel(getCurrentActivity(),categoryId);
+                createNotificationChannel(getCurrentActivity(),channelId);
                 Intent intent = new Intent(getCurrentActivity(), AlarmReceiver.class);
                 intent.putExtra("title", title);
                 intent.putExtra("message", body);
@@ -199,7 +194,7 @@ public class HolaModule extends ReactContextBaseJavaModule {
                 intent.putExtra("categoryId",categoryId);
                 intent.putExtra("msg_id",i);
                 intent.putExtra("mode",mode);
-                intent.putExtra("channelID",CHANNEL_ID);
+                intent.putExtra("channelID",channelId);
                 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
                 PendingIntent pendingIntent = PendingIntent.getBroadcast(
@@ -267,7 +262,19 @@ public class HolaModule extends ReactContextBaseJavaModule {
 
     private void createNotificationChannel(Context context,String channelId) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-            NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
+            String channelName = "";
+            switch (channelId) {
+                case "REMINDER_FS":
+                    channelName = "Reminders for Fasting and Sleep";
+                    break;
+                case "REMINDER_FS_EXTRA":
+                    channelName = "Extra Reminders for Fasting and Sleep";
+                    break;
+                case "REMINDER_SUN":
+                    channelName = "Reminders for Sunrise & Sunset";
+                    break;
+            }
+            NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
 //            channel.setDescription(CHANNEL_DESCRIPTION);
 
             NotificationManager notificationManager = context.getSystemService(NotificationManager.class);

文件差异内容过多而无法显示
+ 1 - 1
ios/main.jsbundle


+ 9 - 1
src/pages/notification/setting.tsx

@@ -27,6 +27,13 @@ export default function Page() {
 
     }
 
+    function goSetting(){
+        if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
+            var Jto = require('react-native').NativeModules.NativeBridge;
+            Jto.openNotificationSettings()
+        }
+    }
+
     function free() {
         return <View className="setting_container">
             <View className="setting_section">
@@ -94,11 +101,12 @@ export default function Page() {
                     // console.log('segment item click', e)
                 }} />
         </View> */}
+
         {
             segmentIndex == 1 ? free() : pro()
         }
         {
-            process.env.TARO_ENV=='weapp' && kIsAndroid && <View className="setting_tip">
+            process.env.TARO_ENV=='rn' && kIsAndroid && <View className="setting_tip" onClick={goSetting}>
                 <Text className="setting_tip_text">Jump to App's Notifications settings{'>>'}</Text>
             </View>
         }

部分文件因为文件数量过多而无法显示