Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

android - How to open a screen from Backendless push notification?

I'm using the Backendless push notification service, and I'm receiving the notification on my device. Backendless push notification accepts a parameter which is the name of the activity that I want to open on notification press. but I'm working with Dart, and in android classes, there is only MainActivity, and suppose I've created a new activity when pressing the notification, the new activity will open, and the device screen becomes black because an empty activity is shown.

package com.example.example;

import io.flutter.app.FlutterActivity;
import android.util.Log;
import android.os.Bundle;

public class SecondActivity extends FlutterActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i( "TAG","activity created");
    }
}

Now in Backendless push notification documentation, I can override a method that will be invoked whenever a notification received. and this is the class that I've created and whenever a push notification is sent from Backendless, I'm receiving it in the onMessage method:

package com.example.example;

import com.backendless.push.BackendlessFCMService;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class PickAppFCMService extends BackendlessFCMService {
    private static final String TAG = BackendlessFCMService.class.getSimpleName();

    @Override
    public boolean onMessage(Context appContext, Intent msgIntent) {
        String action=msgIntent.getStringExtra("action");
        Log.i( TAG,"notification received");
        return true;
    }
}

in this way, there are two problems, first this work whenever a notification is received and what I need is on notification pressed. The second problem, after solving the first problem, how to push a screen to the navigator on dart when a notification is pressed.

What i want to achieve: On click on received notification from Backendless, open a specific screen in dart( run a dart method maybe, that contains Navigator.push(...)).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...