我正在使用React-Native开发一个应用程序,并且需要添加一个后台服务来检查通知。而且我已经尝试了几乎所有解决方案,包括Internet上的Headless JS,但我仍然做不到。也许我做错了。有人可以建议我吗? (即使应用未打开)
答案 0 :(得分:0)
有许多可以使用的软件包可以帮助您实现这一目标。 正如您还没有提到的,任何使用过的软件包都可能会引起一些提示:
我在React本机中使用了以下软件包用于Radio应用程序。 以下软件包可帮助我实现所有与后台相关的活动,即使该应用程序被最小化并使用了另一个应用程序(该应用程序在后台进程中运行)。
@GET
@Path("/{phoneNumber}")
@Produces(MediaType.APPLICATION_JSON)
public Response query() throws InterruptedException, ExecutionException
{
log.debug("get a request");
String message = calculateAsync().get();
return Response.ok(message).build();
}
public Future<String> calculateAsync() throws InterruptedException
{
CompletableFuture<String> completableFuture = new CompletableFuture<String>();
completableFuture = CompletableFuture.supplyAsync(() ->
{
try {
Thread.sleep(10000);
log.debug("finish waiting");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "hello";
});
return completableFuture;
}