OneSignal @Override不适用于类型 [英] OneSignal @Override not applicable to type

查看:138
本文介绍了OneSignal @Override不适用于类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{Android新手开发人员}

{Novice Android Developer}

我正在关注

I am following this tutorial regarding adding OneSignal Push notifications to my application. One thing that I am having difficulty with is the adding of the MainActivity.java code found at the end of the tutorial. I receive multiple errors.

如果有人能够协助我完成OneSignal集成的最后一部分,我将非常有义务.我遇到的主要问题是关于MainActivity中已有的内容以及本教程中提到的内容,这段代码的位置.

I would be much obliged if someone would be able to assist me with this last portion of OneSignal integration. The main issue I am having is the placement of this code in regards to what is already in the MainActivity and what the tutorial mentions.

当我在教程中插入代码时,我收到一条错误消息: @Override不适用于类型

When I insert the code where the tutorial says, I receive an error which says @Override not applicable to type

项目的GitHub存储库

// This fires when a notification is opened by tapping on it or one is received while the app is running.
private class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
    @Override
    public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
        try {
            if (additionalData != null) {
                if (additionalData.has("actionSelected"))
                    Log.d("OneSignalExample", "OneSignal notification button with id " + additionalData.getString("actionSelected") + " pressed");

                Log.d("OneSignalExample", "Full additionalData:\n" + additionalData.toString());
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }

这是我所指的代码.

*注意 我在代码中省略了该教程的其他部分,因为我知道该部分内容.

*Note I omitted other parts of the tutorial in the code for the reason that I am aware of that portion of the tutorial

推荐答案

这意味着函数名称或参数不正确.或者该函数根本不存在于库中.根据OneSignal的文档,正确的签名是

That means either the name of the function or the parameters are not correct. Or that function doesn't exist in the library at all. According to OneSignal's docs, the correct signature is

public void notificationOpened(OSNotificationOpenResult result)

因此该教程适用于其他版本,或者该教程永远无法正常工作.

So either that tutorial is for a different version or the tutorial was never working.

这篇关于OneSignal @Override不适用于类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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