如何用两个解析帐户“一”工作程序 [英] How to work with two Parse account in 'one' app

查看:147
本文介绍了如何用两个解析帐户“一”工作程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在创建几个'pre-安装的应用程序的Andr​​oid启动。这些应用程序实际上是相同的code的一部分,虽然给用户,并从出角度来看,这些应用程序是不同的逻辑单元。

We are creating an Android launcher with several 'pre-installed' apps. These apps are actually part of the same code though to the user and from out perspective these apps are different logical units.

我们使用Parse核心工作,并想将数据分割成两个不同的逻辑应用。能不能做到?

We work with Parse Core and would like to split the data into two different logical 'apps'. Can it be done?

我们认为不同的应用和放大器叫'Parse.initialize数次;客户端密钥,但那么我们应该如何进行不同的应用报告?

We thought to call 'Parse.initialize' several times with different App & Client keys but then how should we proceed to report to different apps?

感谢。

推荐答案

我曾经面临完全一样的问题,几个月前。 ATLEAST,我是不是开发一个发射器。所以,我张贴我的解决下面的问题。

I have faced exactly the same issue a few months ago. Atleast, I was not developing a launcher. So, I'm posting my solution to the problem below.

注:不能使用Parse SDK做

Note: You cannot do it with Parse SDK

因此​​,解决办法是通过让您的应用程序暴露自己的API来做到这一点。这有几个优点,例如,你的解析,应用程序可以通过不同的帐户所拥有,而不是违反使用的解析条款。

So the solution is to do it by having your app expose their own APIs. This has several advantages such as, your parse-apps could be owned by different accounts, while not violating the Parse terms of use.

创建两个不同的应用程序和揭露API的使用云code。使用REST客户端交易数据来回。

Create two different apps and expose the API's using cloud code. Use a REST client to transact data back and forth.

第一步是创建两个语法分析的应用程序,你觉得适合你的发射器软件的个性化需求。您可以产生前preSS服务器了解这两个应用程序。从本质上讲,这一步的结果是,你将与你自己的API两种不同的应用程序被消耗。

The first step is to create two parse-apps, that you think suits individual needs of your launcher software. You can generate express servers for both the apps. Essentially, the result of this step is that, you will have two different apps with your own APIs to be consumed.

现在干掉你也许可能使用目前解析的SDK。选择合适的REST客户端,在我的情况下,它是改造。配置这样一种方式,它可消耗不同基网址个别呼叫。下面是一个改造具体例子

Now get rid of the Parse SDKs you might probably be using currently. Select a suitable REST client, in my case it was retrofit. Configure it such a way that it can consume different base-URLs for individual calls. The following is a Retrofit specific example.

返回一个REST适配器与基础URL的功能

public FirstAppApi getFirstAppApi() {
    return new RestAdapter.Builder()
                          .setEndpoint("http://app-one.parseapp.com/")
                          .build()
                          .create(FirstAppApi.class);
}

在这个例子中 FirstAppApi 本质上是一个改造的界面。同样,您可以创建第二解析应用适配器为好。现在,做一个数据交易,它只是决定你应该使用哪些应用程序的问题。见下文的几个例子。

In this example FirstAppApi is essentially a Retrofit interface. Similarly, you can create adapter for the second parse-app as well. Now, to do a data transaction, its just a matter of deciding which app you should use. See a few examples below.

// Get an author from the first Parse app
Author author = getFirstAppApi().getAuthorByName("Shakespeare");

// Get books of the author from the second Parse app
List<Book> books = getSecondAppApi().getBooksByAuthor(author);

有几件事情需要在此实现被照顾。 API被公开曝光,eventhough应用程序名称,因而基URL只知道给你。因此,该API应当很好地完成时固定。你应该加倍使用Parse家伙,它不违反其使用条款确认。

A few things needs to be taken care in this implementation. The API is exposed publicly, eventhough the app name, and thus the base-url is known only to you. So, the API should be well secured when completed. You should double confirm with Parse guys that it does not violate their terms of use.

这篇关于如何用两个解析帐户“一”工作程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆