小编how*_*wly的帖子

无法从Firebase 3.2.0主题接收iOS上的推送通知

我在https://firebase.google.com/docs/notifications/ios/console-topics#receive_and_handle_topic_messages上按照谷歌的教程来订阅我的iOS应用上的Firebase主题.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {

    FIRMessaging.messaging().subscribeToTopic("/topics/Notifications")

    let homeViewController = UINavigationController(rootViewController: HomeViewController())

    UINavigationBar.appearance().translucent = false
    window = UIWindow(frame: UIScreen.mainScreen().bounds)
    window?.rootViewController = homeViewController

    window?.makeKeyAndVisible()
    return true
}
Run Code Online (Sandbox Code Playgroud)

但是,当我从Firebase控制台发送主题推送通知时.我无法收到任何推送通知.但是当我从控制台向用户段发送推送通知时,推送工作正常.当我检查Xcode控制台时,我看到了这个FIRMessaging错误.

2016-05-31 11:11:47.893: <FIRMessaging/WARNING> Cannot subscribe to topic: /topics/Notifications with token: (null) 
Run Code Online (Sandbox Code Playgroud)

我试图搜索这个错误,但没有找到任何运气.我不确定这是否是导致我的应用程序无法接收任何主题推送的问题.

有没有人有这个问题,知道如何解决它?

push-notification ios firebase swift2

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

来自 ExecutorService 的线程是否可以保证更新本地声明的并发哈希图?

public void test() {

    List<Integer> integers = new ArrayList<>();
    for(int i = 0; i < 1000; i++) {
        integers.add(i);
    }

    Map<Integer, Integer> cache = new ConcurrentHashMap<>();
    ExecutorService pool = new ForkJoinPool(10);
    try {
        pool.submit(() -> integers.parallelStream().forEach(integer -> {
            String name = Thread.currentThread().getName();
            System.out.println("Foo " + name);
            cache.put(integer, integer);
        })).get();
    } catch (Exception e) {

    }

    System.out.println(cache);
}
Run Code Online (Sandbox Code Playgroud)

我读到您将需要具有 volatile 变量以确保对变量的更新可预测地传播到其他线程。http://tutorials.jenkov.com/java-concurrency/volatile.html#variable-visibility-problems

在这个测试方法中,我不能将“缓存”并发哈希图声明为“易失性”变量,因为它是一个局部变量而不是一个实例变量。当代码到达 System.out.println(cache) 行时,它是否能保证我的主线程会看到 ExecutorService 线程添加到“缓存”的所有值?

java multithreading executorservice java-8 java-stream

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

使用JSQMessageViewController隐藏AvatarImage会导致白色空白

我正在使用JSQMessageViewControllers库来实现聊天视图.但是,我想隐藏聊天中的头像图像.

根据以下文档.http://cocoadocs.org/docsets/JSQMessagesViewController/7.2.0/Protocols/JSQMessagesCollectionViewDataSource.html#//api/name/collectionView:avatarImageDataForItemAtIndexPath:

我只需要在以下函数中返回nil.

override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource! {
    return nil
}
Run Code Online (Sandbox Code Playgroud)

然而,在返回零之后.它为原始头像位置的每条消息都有空格. 聊天图片

我们怎样才能删除空格?

swift jsqmessagesviewcontroller swift2

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