我正在尝试设置动态链接,以便链接将用户深度链接到应用程序(如果他们已经安装了该应用程序)和游戏商店(如果没有安装)。我希望该链接能够在 Play 商店安装过程中保留下来,并与该链接一起发送到启动器活动。当应用程序已安装时,动态链接将起作用。但是,当应用程序未安装时,它会将用户发送到 Play 商店,但动态链接不会在安装过程中保留下来。我读过,当用户通过动态链接发送到游戏商店时,“打开”按钮应该更改为“继续”,但当我这样做时,它仍然显示“打开”。这是我在 AndroidManifest.xml 中的活动。
<activity android:name=".share.DeepLinkActivity"
android:theme="@style/AppTheme"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="housebook.com"
android:scheme="https"/>
<data
android:host="housebook.com"
android:scheme="http"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="housebook.page.link"
android:scheme="https"/>
<data
android:host="housebook.page.link"
android:scheme="http"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
这是我的 DeepLinkActivity
package chenige.chkchk.wairz.share
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import chenige.chkchk.wairz.BaseActivity
import chenige.chkchk.wairz.landing.LandingActivity
import chenige.chkchk.wairz.model.ShareDeepLink
import chenige.chkchk.wairz.sign_in.SignInActivity
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.dynamiclinks.FirebaseDynamicLinks
class DeepLinkActivity : BaseActivity() {
companion object { …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用程序中设置深层链接。我已经设置了应用程序以及推送通知。但是,我无法完成 AppDelegate 接收用户单击我想要深层链接到的屏幕的通知的最终链接。我基本上想从 AppDelegate 调用 viewRouter.goToFred() 。我在这里设置了一个 git 存储库(https://github.com/cameronhenige/SwiftUITestDeepLink),其中包含一个应用程序,该应用程序已设置好除最后一部分之外的所有内容。有人可以帮我解决这个问题吗?这是相关的代码片段。谢谢!
import SwiftUI
struct MainView: View {
@EnvironmentObject var viewRouter: ViewRouter
var body: some View {
NavigationView {
List {
ForEach(viewRouter.pets) { pet in
NavigationLink(
destination: PetView(),
tag: pet,
selection: $viewRouter.selectedPet,
label: {
Text(pet.name)
}
)
}
Button("Send Notification to Fred") {
viewRouter.sendNotification()
}
Button("Manually go to Fred") {
viewRouter.goToFred()
}
}
}
}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
MainView()
}
}
Run Code Online (Sandbox Code Playgroud)
import SwiftUI …Run Code Online (Sandbox Code Playgroud) 我遇到了一个奇怪的 SwiftUI 崩溃,我不明白。我有一个 TabView,其中包含 3 个图像的列表。我试图通过点击屏幕上的按钮从列表中删除第一张图像,但我遇到了这个崩溃。
'NSInternalInconsistencyException',原因:'尝试删除并重新加载相同的索引路径(<NSIndexPath:0x968bfe135e5a98d1> {length = 2,path = 0 - 0})'以未捕获的NSException类型异常终止
如果我从代码中删除 TabView,它会按预期工作并删除第一项。以下是重现此崩溃所需的最少代码量。我还在这里创建了此代码的 Git 存储库 -> https://github.com/cameronhenige/TestCrash有人可以帮我弄清楚发生了什么吗?
import SwiftUI
struct ContentView: View {
@StateObject var testViewModel = TestViewModel()
var body: some View {
GeometryReader { proxy in
ScrollView {
VStack(alignment: .leading, spacing:0) {
TabView {
ForEach(testViewModel.images, id: \.self) { image in
Image(image)
}
}.tabViewStyle(PageTabViewStyle())
.clipShape(RoundedRectangle(cornerRadius: 15))
.padding()
.frame(width: proxy.size.width, height: proxy.size.height/2.5)
}
Button(action: {
testViewModel.removeFirst()
}) {
Text("Remove first item from list")
}
}
}.frame(maxWidth: .infinity).background(Color.black) …Run Code Online (Sandbox Code Playgroud) 我想创建一个视图,该视图有一个表单,其下方有一个按钮。如果我包含一个表单和一个按钮,该按钮将显示在屏幕底部。
这只是 SwiftUI 的一个 bug 吗?或者我做错了什么?
//
// TestFile.swift
// searchparty
//
// Created by Me
//
import SwiftUI
struct TestFile: View {
var body: some View {
VStack {
Form{
Text("Hello, World!")
}
Button("Button") {
print("Button tapped!")
}
}
}
}
struct TestFile_Previews: PreviewProvider {
static var previews: some View {
TestFile()
}
}
Run Code Online (Sandbox Code Playgroud)