小编ask*_*ale的帖子

Firebase FCM InternalServerError

我大约一个月前在我的应用程序中实现了Firebase FCM,从那时起它一直很好用,直到今天.当我尝试从我的控制台发送推送通知时,什么都没有出现.我觉得这很奇怪,因为它在我昨天上床睡觉前有效.我也有一个PHP脚本发送推送通知(FCM),这也是有效的 - 但是当我尝试使用它来发送推送通知时,我得到了这个:

{"multicast_id":5593178441415796544,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InternalServerError"}]}

我觉得这很奇怪.我用Google搜索了一下,我读了一些关于重新生成我的APNS证书的事情(因为它们可能是错的或者其他的东西),我认为这也很奇怪,因为我昨天也创建了新证书(这是有效的) .现在我再次尝试删除,并生成新的 - 没有任何运气.

我还想指出,当我访问Firebase中的"云消息"选项卡,配置我的证书时,我无法删除 - 只能重新上传.

这可能是什么?我检查了我的证书,我的API密钥是正确的.它在10小时前工作了100%.

这可能是Firebase问题,或者我该如何解决?非常感谢帮助.

firebase firebase-cloud-messaging

9
推荐指数
1
解决办法
2415
查看次数

Swift Firebase发送推送通知

我想知道如何通过我的应用程序通过Firebase发送推送通知?我现在只能从我的Firebase Notification-console发送推送通知,但我想弄清楚如何以编程方式发送一个.关于我在哪里可以找到更多信息的任何想法?请指出我正确的方向!我试图通过Firebase(快速入门)查看GitHub上的一个项目,但我不得不说包含该项目的信息很少.我很幸运能在YouTube上找到一个教程,至少让我自学了如何使用远程通知.

提前致谢!

push-notification firebase swift firebase-cloud-messaging

5
推荐指数
1
解决办法
3975
查看次数

URLSession dataTask超时错误

我目前在尝试将数据发布到Web服务器时遇到有关URLSession的一些问题。但是,这很完美。似乎无效的是我设置的超时时间。这对于我的整个应用程序至关重要,因为我不希望用户永远被“加载”,而不会出现任何类型的错误消息。这是我的代码:

var request = URLRequest(url: URL(string: "https://www.mywebsite.com/file.php")!, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: 20)

let urlconfig = URLSessionConfiguration.default
urlconfig.timeoutIntervalForRequest = 20
urlconfig.timeoutIntervalForResource = 20

request.httpMethod = "POST"
let session = URLSession(configuration: urlconfig, delegate: self, delegateQueue: nil)//URLSession.shared
let body = "receiver=\(receiverID)"
request.httpBody = body.data(using: String.Encoding.utf8, allowLossyConversion: true)
request.timeoutInterval = 20

session.dataTask(with: request) {data, response, err in
    if err == nil {
        do {
            let jsonResult:NSDictionary? =  try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as? NSDictionary
            let jsonComp = jsonResult?.value(forKey: "completion") as! String
            if jsonComp == "done" …
Run Code Online (Sandbox Code Playgroud)

urlrequest connection-timeout nsurlsession swift swift3

5
推荐指数
1
解决办法
7618
查看次数

Heroku 没有这样的文件或目录,stat '/app/client/build/index.html'

我已经为这个错误苦苦挣扎了将近三个星期了,老实说,这让我发疯了。我已经使用 Heroku 来部署我的项目一年多了,在我要发布我的这个新网站之前,我从未遇到任何错误。你看,我目前在我的节点项目中安装了一个名为“index.js”的邮件服务器,而我的完整 React 项目位于一个名为 client 的文件夹中。

在此处输入图片说明 现在,这就是奇怪的地方。我的 index.js 看起来像这样:

if (process.env.NODE_ENV === 'production') {
    app.use(express.static('client/build'));
    const path = require('path');
    app.get('*', (req, res) => {
      res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
    });
  }
Run Code Online (Sandbox Code Playgroud)

但是每次我推送到 Heroku 时,我都会在控制台中收到此错误消息:

Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
Run Code Online (Sandbox Code Playgroud)

我也一直在尝试更改和修改路径中的目录,看看是否有任何变化。我还浏览了整个互联网关于此问题的潜在解决方案的感觉,但没有任何运气。如果有人至少能指出我在这里似乎做错的正确方向,我将不胜感激。

提前致谢。

heroku reactjs heroku-cli

5
推荐指数
2
解决办法
6432
查看次数

奇怪的Create-React-App Heroku错误-无法获取/

因此,我几天来一直在努力解决这个问题,几乎尝试了所有我遇到的论坛建议。基本上,我已经设置了一个后端服务器,以便允许我自己通过节点发送电子邮件。奇怪的是,它在我的本地计算机上运行良好,甚至在我推送到Heroku时也可以完美构建和部署。但是,仍然提示我“无法获取/”。

这是我的文件结构:

PROJETNAME
- client
     ^--
        ^-- build
        ^-- node_modules
        ^-- public
        ^-- src
- node_modules
- .gitignore
- package.lock.json
- package.json
- server.js
Run Code Online (Sandbox Code Playgroud)

这是我的package.json在根(后端)文件夹中:

{
  "name": "sendemail",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "devDependencies": {},
  "cacheDirectories": [
    "node_modules",
    "client/node_modules"
  ],
  "engines": {
    "node": "8.9.x"
  },
  "keywords": [
    "node",
    "heroku",
    "create-react-app",
    "react"
  ],
  "scripts": {
    "start": "node server.js",
    "server": "nodemon server.js",
    "client":"npm run start --prefix client",
    "dev":"concurrently \"npm run server\" \"npm run client\"",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && …
Run Code Online (Sandbox Code Playgroud)

build heroku node.js reactjs

4
推荐指数
1
解决办法
1908
查看次数

Swift:在字典数组中访问数组值

我目前正在努力从字典数组中的数组中获取值。基本上,我想从存储在字典数组中的数组中获取第一个“ [0]”。这基本上是我所拥有的:

var array = [[String:Any]]()
var hobbies:[String] = []
var dict = [String:Any]()
Run Code Online (Sandbox Code Playgroud)

viewDidLoad代码:

dict["Name"] = "Andreas"
hobbies.append("Football", "Programming")
dict["Hobbies"] = hobbies
array.append(dict)
Run Code Online (Sandbox Code Playgroud)

///-但是,我只能使用以下代码显示名称:

var name = array[0]["Name"] as! String
Run Code Online (Sandbox Code Playgroud)
  • 但是我也希望能够在存储有名称的数组中显示第一个值。这怎么可能?

是的; 我知道这种方法还有其他选择,但是这些值来自Firebase(子路径)-但是我只需要找到一种在字典数组中显示数组的方法。

提前致谢。

arrays dictionary swift

3
推荐指数
1
解决办法
5111
查看次数

从函数中检索字符串值,并在Swift中使用闭包

我正在尝试从Firebase检索字符串值,以便为每个用户名提供一个传递给该函数的唯一UID,该函数返回用户的用户名.但是 - 由于firebase ObserveEvent存在closures,我无法返回任何值,因为操作是异步的(?).我想知道这是否是实现这一目标的一种方式?

该函数如下所示:

func GetUsername(uid:String) -> String {
    var username = String()
    firebase.child("Users").child(uid).observeSingleEventOfType(.Value) { (snapshot:FIRDataSnapshot) in

        username = snapshot.value!["Username"] as! String

    }

    return username
}
Run Code Online (Sandbox Code Playgroud)

显然这不起作用,但我希望能够通过GetUsername("whatevertheidmightbe")来获取数据.想法?

closures firebase swift firebase-realtime-database

2
推荐指数
1
解决办法
1978
查看次数

Swift Firebase Access子快照数据

我目前正在尝试从Swift中的子快照访问数据。这是我的代码(在Swift 3 / Firebase更新之前有效):

 if let achievements = snapshot1.childSnapshotForPath("Achievements").children.allObjects as? [FIRDataSnapshot] {


                    if achievements.count != 0 {

                        if let val = achievements[0].value!["somevalue"] as? Int {
                            self.dict["somevalue"] = val
                        }


                    }
Run Code Online (Sandbox Code Playgroud)

因此,我在这里要做的是创建一个子快照(成就)的变量,并从中访问子快照数据。成就[0]将仅返回第一个值。但是,这似乎不起作用。我应该如何处理?

我目前正在快照中(“ observeType:.ChildAdded”)进行此操作

我的Firebase数据库如下所示:

Achievements{

randomId1 {
somevalue : somevalue
}

randomId2 {
somevalue2 : somevalue2
}
}
Run Code Online (Sandbox Code Playgroud)

更新的代码:

 func loadData() {

        ref.child("Players").observe(FIRDataEventType.childAdded) { (snapshot:FIRDataSnapshot) in

            if let value = snapshot.value as? [String:AnyObject], let username = value["Username"] as? String {

            }

            if let value = snapshot.value as? [String:AnyObject], let ranking …
Run Code Online (Sandbox Code Playgroud)

ios firebase swift firebase-realtime-database

2
推荐指数
1
解决办法
2092
查看次数

Swift UICollectionView iPad流程布局不起作用

目前在iPad上使用集合视图遇到Flow布局的一些问题.我目前正在开发一个应用程序,它以流布局显示帖子,使其看起来美观而时尚.但是,在所有设备上测试应用程序时,我注意到显示更改:

  • iPad第5代
  • iPad Air
  • iPad Air 2
  • iPad Pro(9,7英寸)

但剩下的iPad,它显示正常.这里似乎有什么问题?我目前正在使用此代码在CollectionView中设置我的布局样式:

 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

        switch UIDevice().screenType {
        case .iPhoneX:
            return CGSize(width: 180.0, height: 180.0)
            break
        case .iPhone5:
            return CGSize(width: 152.0, height: 152.0)
            break
        case .iPhone6:
            return CGSize(width: 180.0, height: 180.0)
            break
        case .iPhone6Plus:
            return CGSize(width: 200.0, height: 200.0)
            break
        case .iPad:
            return CGSize(width: 400.0, height: 400.0)
            break
        case .iPadTwo:
            return CGSize(width: 400.0, height: 400.0)
            break
        case .iPadThree:
            return CGSize(width: 400.0, height: …
Run Code Online (Sandbox Code Playgroud)

layout ipad ios uicollectionview swift

2
推荐指数
1
解决办法
540
查看次数

Swift/Firebase数据库无效令牌错误

遇到Firebase的一些相当奇怪的问题..我已经通过cocoaPods安装了firebase,包括GoogleService-Info.plist等 - 但是当我尝试从Firebase读取值时,我收到此错误:

2016-06-16 12:10:04.598 MP [78421:13128189] [FirebaseDatabase]身份验证失败:invalid_token(身份验证令牌中的声明'aud'无效.)

每次我尝试开始一个新项目时都会得到这个,除了一次 - 但我现在已经放弃了这个项目,因为我正在开始一个新项目.这是简单的代码:

import UIKit
import Firebase
import FirebaseDatabase
class ViewController: UIViewController {
    var ref:FIRDatabaseReference!
    override func viewDidLoad() {
        super.viewDidLoad()
        ref = FIRDatabase.database().reference()
        ref.observeSingleEventOfType(.Value) { (snapshot:FIRDataSnapshot) in
            var val = snapshot.value! as? String
            print(val)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

firebase firebase-authentication firebase-realtime-database

1
推荐指数
1
解决办法
2424
查看次数

反应路由器 404 页面

我目前遇到一些关于反应路由器显示 404 未找到页面的问题。这是我到目前为止的代码:

 <Route path="/home" component={Home} exact={true}/>
 <Route path="/admin/forgot-password" component={AdminResetPassword} exact={true}/>
 <Authentication path="/admin/welcome" component={AdminWelcome} exact={true}/>
 <Authentication path="/admin/dashboard" component={AdminDashboard} exact={true}/>
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试做这样的事情:

<Route path="/home" component={Home} exact={true}/>
<Route path="/admin/forgot-password" component={AdminResetPassword} exact={true}/>
<Route path="*" component={Page404}/>
<Authentication path="/admin/welcome" component={AdminWelcome} exact={true}/>
<Authentication path="/admin/dashboard" component={AdminDashboard} exact={true}/>
Run Code Online (Sandbox Code Playgroud)

事实是,它有效 - 但仅适用于未包含在身份验证中的页面。换句话说,如果我尝试导航到管理页面,它只会说找不到 404 页面。我将如何解决这个问题?

帮助将不胜感激。

reactjs react-router

1
推荐指数
1
解决办法
1690
查看次数