Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could we expose getPushToStartToken so we can use it please, that would be amazing, thaaaaaanks #103

Open
MortadhaFadhlaoui opened this issue Nov 21, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@MortadhaFadhlaoui
Copy link

No description provided.

@MortadhaFadhlaoui MortadhaFadhlaoui changed the title could you expose getPushToStartToken so we can use it please could we expose getPushToStartToken so we can use it please, that would be amazing, thaaaaaanks Nov 21, 2024
@MortadhaFadhlaoui MortadhaFadhlaoui changed the title could we expose getPushToStartToken so we can use it please, that would be amazing, thaaaaaanks Could we expose getPushToStartToken so we can use it please, that would be amazing, thaaaaaanks Nov 21, 2024
@istornz istornz added the enhancement New feature or request label Nov 26, 2024
@istornz
Copy link
Owner

istornz commented Nov 26, 2024

Thanks for raising an issue, I will implement it ASAP :)

@mpsal
Copy link

mpsal commented Feb 2, 2025

workaround for now:

import 'package:flutter/services.dart';

const MethodChannel _channel = MethodChannel("live_activities");

void listenForPushTokens(Function(String) onTokenReceived) {
  _channel.setMethodCallHandler((MethodCall call) async {
    if (call.method == "onPushTokenReceived") {
      final String token = call.arguments;

        onTokenReceived(token);
      }
    });
}

Then send it to you db like this

  syncAPTSToken() async {
    listenForPushTokens((token) {
      //only update if token changed
      if(lastApplePushToStartToken!=token) {
        lastApplePushToStartToken = token;
        FirebaseFirestore.instance
            .collection(DBFields.user)
            .doc(getUserId())
            .set({
          DBFields.aptsToken: token,
        }, SetOptions(merge: true));
      }
    },);
  }


In this example I store the token locally to only upload new tokens.
Also make sure to call syncATPSToken() when starting your app

@RahnRazamai
Copy link

@mpsal have been able to trigger the live activities by APNs/firebase push? from my side it wont trigger. same with update.

@mpsal
Copy link

mpsal commented Feb 6, 2025

@RahnRazamai I haven't yet, I assume that the issue is related to firebase though. Their documentation is very limited on this topic and the feature seems to be quite new.

Since the message should invoke the live activity directly, I doubt that this is related to the plugin, as long as the push token is correct (which it should be since the method for obtaining it is the same method I would use in appdelegate.swift)

have you tried directly using APNS?

Please let me know if you have reason to believe this is related to the plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants