Description:
So I'm developing an app which receives pushes and should open a specific page based on data {'post': 234} for example.
This works when app is open or is just recently closed.
When app is "swiped away" or have been closed after not using in a while I cant access the data.
I've read many issues with same problem but none of them have helped me with a solution or in which way I should go.
Should this be possible with just the packaged installed? Maybe I just set something up wrong
If not, could this be solved by writing a Service Extension like here ?
I've no experience in kotlin or swift so really don't want to write a service extension if it's not going to solve the problem
Environment
Android
onesignal_flutter: ^2.3.1Steps to Reproduce Issue:
Howdy, are you seeing this in Android and iOS?
both iOS and android.
I solved android by writing platform-specific code. Haven't figured out iOS yet but I think i'll get there. I was planning to share documentation how to implement it when I get iOS to work.
Howdy,
Thanks for your patience.
Do you have any further information to provide that could help us either solve the issue or better document how to handle it?
I think the documentation could be more clear on how to implement the notification extender on Android. I'll close this issue now and below is how i solved it for anyone who run into the same problem. Feel free to re-open if the discussion about the documentation will take place here.
This is my MainActivity.kt
import com.onesignal.NotificationExtenderService.OverrideSettings
import com.onesignal.OSNotificationReceivedResult
import com.onesignal.NotificationExtenderService
import androidx.core.content.ContextCompat.getSystemService
import io.flutter.plugin.common.MethodChannel
class MainActivity: FlutterActivity() {
private val CHANNEL = "YOUR_IDENTIFIER/noti"
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler{ call, result ->
if (call.method == "getPostId") {
var res = PostData.postId
result.success(res)
}
}
}
}
class NotificationExtenderExample : NotificationExtenderService() {
override fun onNotificationProcessing(receivedResult: OSNotificationReceivedResult): Boolean {
val title = receivedResult.payload.additionalData["post"]
PostData.setPost(receivedResult.payload.additionalData.getString("post"))
return false
}
}
object PostData {
var postId = ""
fun setPost(id: String) {
postId = id
}
}
Thank you for the details
Most helpful comment
both iOS and android.
I solved android by writing platform-specific code. Haven't figured out iOS yet but I think i'll get there. I was planning to share documentation how to implement it when I get iOS to work.