我正在测试新的Google支持的Firebase,并实施了远程通知和崩溃报告.但是,我在使用Analytics工作时遇到了大量问题.
我跟踪事件FIRAnalytics.logEventWithName(...)
并保存用户pproperties FIRAnalytics.setUserPropertyString(...)
.但是,无论我做什么,Firebase Analytics控制台中都不会显示任何数据.
好吧,我确实收到了一些事件,但这些事件并非由我发送(如first_open和session_start).此外,这些数据似乎在很长一段时间后都会下降.
此外,当我跟踪事件并保存用户数据时,我收到以下内容:
Upload task scheduled to be executed in approx. (s): 3102.294599890709
这看起来很奇怪 - Firebase在尝试发送下一批数据之前等待差不多一个小时必须是一个bug,还是可以配置?当我等待那么长时间的延迟时,数据被发送......但是没有显示出来.
在Swift中,我历史上使用扩展来扩展封闭类型并提供方便的,无逻辑的功能,如动画,数学扩展等.但是,由于扩展是硬依赖性遍布整个代码库,我总是在实现之前三次思考某事作为延伸.
最近,我已经看到Apple建议在更大程度上使用扩展,例如将协议实现为单独的扩展.
也就是说,如果你有一个实现协议B的A类,你最终会得到这样的设计:
class A {
// Initializers, stored properties etc.
}
extension A: B {
// Protocol implementation
}
Run Code Online (Sandbox Code Playgroud)
当你进入那个兔子洞时,我开始看到更多基于扩展的代码,例如:
fileprivate extension A {
// Private, calculated properties
}
fileprivate extension A {
// Private functions
}
Run Code Online (Sandbox Code Playgroud)
我的一部分就像你在单独的扩展中实现协议时获得的构建块.它使得该类的独立部分非常独特.但是,只要继承此类,就必须更改此设计,因为无法覆盖扩展函数.
我认为第二种方法是......有趣.一旦它成功,那就是你不需要注释每个私有属性并将其作为私有属性,因为你可以为扩展指定.
但是,这种设计还会分割存储和非存储的属性,公共和私有函数,使类的"逻辑"更难遵循(我知道写较小的类).这与子类化问题一起使我在延伸仙境的门廊上停了下来.
很想听听Swift社区如何看待扩展.你怎么看?有一个银色的小礼物吗?
我正在构建一个可以打开地图应用的应用,其中包含从用户当前位置到另一个位置的路线.代码如下所示:
- (id)resolveDirectionsFromCoordinate:(CLLocationCoordinate2D)startCoordinate toCoordinate:(CLLocationCoordinate2D)endCoordinate
{
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
startCoordinate.latitude, startCoordinate.longitude,
endCoordinate.latitude, endCoordinate.longitude];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
return nil;
}
Run Code Online (Sandbox Code Playgroud)
这些在iOS 5.x中运行良好.但是,在iOS 6中,由于地图不再使用Google地图,因此会显示Safari.
有谁知道我应该在iOS 6中调用哪个URL?
我正在尝试构建一个iOS应用程序,列出从设备发出的所有请求,就像Charles Proxy
这样.很像查尔斯,我的想法是创建一个Packet Tunnel Provider
并让它在没有外部VPN服务器的情况下设置本地VPN连接.然后,流量将在内部路由到数据包隧道,而无需外部VPN服务器.
既然如此Charles Proxy
,我知道它在技术上是可行的,但我找不到任何有关如何使用内部VPN连接设置隧道的信息,而不是使用"真正的"外部VPN服务器.人们提到的唯一资源是SimpleTunnel
Apple示例项目,该项目已有几年历史,用Swift 3编写.
我已经下载了SimpleTunnel
示例代码项目,创建了正确的权利,现在可以运行项目并创建一个VPN配置,该配置列在Settings下,但我无法连接VPN隧道.我已经尝试将服务器地址更改为127.1.0.0
和使用IKEv2
,但没有成功.我还在https://github.com/lxdcn/NEPacketTunnelVPNDemo下载了源代码,但也没有让它工作.
有谁知道如何设置内部VPN服务器NetworkExtensions
并让隧道使用该连接?
我正在使用 Firebase 和 Cloud Firestore 构建一个群组应用程序,用户应该能够在其中创建群组并向其中添加成员。
当用户创建一个组时,我想要一个云触发器在创建组后将该用户添加到组的成员列表中。触发器看起来像这样:
exports.addCreatorAsAdmin = firestore
.document('groups/{group}')
.onCreate((snap, context) => {
if (context.auth == null) { return unauthorizedError() }
const path = `groups/${context.params.group}/members/${context.auth.uid}`;
return db.doc(path).create({});
});
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序、登录用户并创建团队时,该功能被正确触发。但是,我总是遇到未经授权的错误,这意味着它context.auth
为空。
TLDR;用户已正确登录,但触发器未经授权。谁能帮我吗?
node.js firebase firebase-authentication google-cloud-functions google-cloud-firestore
在带有一个ViewPager
和三个片段的活动中,我想自动隐藏ToolBar
. 为此,我正在使用android.support.design.widget.CoordinatorLayout
.
但是这ViewPager
给了我一些问题。如果在 中CoordinateLayout
,则ToolBar
与活动重叠。如果它CoordinatorLayout
在ToolBar
活动之外,则不与WebView
活动重叠。如果ViewPager
是在外CoordinatorLayout
,自动隐藏不起作用。
任何帮助,将不胜感激。
活动_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/ColorPrimary"
android:elevation="2dp"
android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true" />
<com.taadu.slidechat.adaptor.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我一直在用线性布局尝试,如果ViewPager
是在LinearLayout
活动并不重叠,但是这消除了自动隐藏功能。
我只添加 …