没有Firebase身份验证的Flutter android_alarm_manager

时间:2018-09-09 19:21:40

标签: firebase flutter

我正在尝试使用Flutter android_alarm_manager创建一些后台任务,但如果没有firebase身份验证,似乎无法使其正常工作。我遵循了readme on the plugin,但是仅在import numpy as np from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm import matplotlib.pyplot as plt def main(): # plotting parameters num_polartheta = 12 num_p = 6 num_polarphi = 6 * num_polartheta - 5 # range of hydrostatic stress (p) to plot p = (x + y + z)/3 pmin = 0 pmax = 100 p = np.linspace(pmin, pmax, num=num_p) # 360 degrees in the shperical phi polar_phi = np.linspace(0, 2 * np.pi, num_polarphi) # along theta angle th1 = np.linspace(-np.pi / 6, np.pi / 6, num=num_polartheta) th2 = np.linspace(np.pi / 6, -np.pi / 6, num=num_polartheta) polar_theta = np.r_[th1, th2[1:], th1[1:], th2[1:], th1[1:], th2[1:]] # create grid grd_phi = np.tile(polar_phi, (num_p, 1)) grd_th = np.tile(polar_theta, (num_p, 1)) grd_p = np.tile(p.reshape(num_p, 1), (1, num_polarphi)) # Material parameter # effective friction angle, mat_phi = 30 mat_phi = np.radians(mat_phi) # Matsuoka-Nakai yield surface kmn = (9 - np.sin(mat_phi) ** 2) / (1 - np.sin(mat_phi) ** 2) A1 = (kmn - 3) / (kmn - 9) A2 = kmn / (kmn - 9) sqrtJ2 = grd_p / ( 2 / np.sqrt(3) * np.sqrt(A1) * np.cos(1 / 3 * np.arccos(A2 / A1 ** (3 / 2) * np.sin(3 * grd_th))) ) X = grd_p + np.sqrt(2 / 3) * sqrtJ2 * np.cos(grd_phi + 2 * np.pi / 3) Y = grd_p + np.sqrt(2 / 3) * sqrtJ2 * np.cos(grd_phi) Z = grd_p + np.sqrt(2 / 3) * sqrtJ2 * np.cos(grd_phi - 2 * np.pi / 3) fig = plt.figure() ax = fig.add_subplot(111, projection="3d") surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm) ax.view_init(elev=40, azim=45) ax.set_xlabel(r"$\sigma_1$") ax.set_ylabel(r"$\sigma_2$") ax.set_zlabel(r"$\sigma_3$") plt.show() if __name__ == "__main__": main() 中添加android_alarm_manager插件会导致应用在启动时立即崩溃(模拟器和真实设备)。如何避免Firebase集成并仍然使用警报管理器插件?

1 个答案:

答案 0 :(得分:1)

回复: but can't seem to get it working without the firebase auth

也许在您尝试回到2018年时,您的应用程序中出现了一些意外纠缠或其他问题,但是到目前为止,https://pub.dev/packages/android_alarm_manager不需要任何Firebase。

只需在清单中设置一些权限,服务和接收者,然后此示例即可运行:

import 'package:android_alarm_manager/android_alarm_manager.dart';

void printHello() {
  final DateTime now = DateTime.now();
  final int isolateId = Isolate.current.hashCode;
  print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
}

main() async {
  final int helloAlarmID = 0;
  await AndroidAlarmManager.initialize();
  runApp(...);
  await AndroidAlarmManager.periodic(const Duration(minutes: 1), helloAlarmID, printHello);
}

另请参见/flutter/android_alarm_manager/example/