junny_dev_kit 0.6.5-dev.0 copy "junny_dev_kit: ^0.6.5-dev.0" to clipboard
junny_dev_kit: ^0.6.5-dev.0 copied to clipboard

JunnySoft开发工具包.

JunnySoft Dev Kit #

公共开发工具

Getting Started #

dependencies:
  junny_dev_kit: ^latest_version // 替换成最新的版本号

导入开发包

import 'package:junny_dev_kit/junny_dev_kit.dart';

安卓的权限依赖 #

    <!-- 访问网络状态-->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

    <!-- 外置存储存取权限 -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
    
    <!-- For android 13/API33 -->
    <!-- Add this if you need to take photos. -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    
    <!--Starting with API 33. this permission is needed for notifications-->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- 控制呼吸灯,振动器等,用于新消息提醒 -->
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    
    <queries>
        <!-- Place inside the <queries> element. -->
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https" />
        </intent>

        <!-- If your app checks for SMS support -->
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="sms" />
        </intent>

        <!-- If your app checks for call support -->
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="tel" />
        </intent>
    </queries>


一些依赖包需要在项目做的各种配置

background_downloader #

Android

No setup is required if you don't use notifications. If you do:

  • Starting with API 33, you need to add <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> to your app's AndroidManifest.xml
  • If needed, localize the button text by overriding string resources bg_downloader_cancel, bg_downloader_pause, bg_downloader_resume and descriptions bg_downloader_notification_channel_name, bg_downloader_notification_channel_description.

Using foreground service on Android targeting API 34 #

If targeting API 34 or greater, you must add to your AndroidManifest.xml a permission declaration <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> and the foreground service type definition (under the application element):

<service
  android:name="androidx.work.impl.foreground.SystemForegroundService"
  android:foregroundServiceType="dataSync"
  tools:node="merge" />

iOS

On iOS, ensure that you have the Background Fetch capability enabled:

  • Select the Runner target in XCode
  • Select the Signing & Capabilities tab
  • Click the + icon to add capabilities
  • Select 'Background Modes'
  • Tick the 'Background Fetch' mode

Note that iOS by default requires all URLs to be https (and not http). See here for more details and how to address issues.

If using notifications, add the following to your AppDelegate.swift:

UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate

or if using Objective C, add to AppDelegate.m:

[UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;

back_button_interceptor #

To make it work on Android 13 and up, set this to false in the Android manifest:

<activity
    android:name=".MainActivity"
    android:enableOnBackInvokedCallback="false">