OneSignal @Override not applicable to type

只谈情不闲聊 提交于 2019-12-25 08:26:02

问题


{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.

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.

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

GitHub Repo of Project

// 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();
        }

This is the code I am referring to.

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


回答1:


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.



来源:https://stackoverflow.com/questions/42173061/onesignal-override-not-applicable-to-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!