istornz / flutter_live_activities

A Flutter plugin to use iOS 16.1+ Live Activities ⛹ī¸ & iPhone Dynamic Island 🏝ī¸ features
https://dimitridessus.fr/
MIT License
179 stars 54 forks source link

What can cause the live activity to not be displayed? #21

Open ahmdaeyz opened 1 year ago

ahmdaeyz commented 1 year ago

Hey! Thanks for the great work! I've tried the example app and it works fine. I also tried to go through the steps on a new project and it worked. But when I try to go through the steps in an existing project. The activity doesn't show up. The activity id gets created normally and If I hooked the creation function call to a button and pressed multiple times I get that the maximum number of activities is reached (as an error).

So is there a unique reason to this?

I've some background modes enabled like remote notification and background fetch. I'm also using Firebase Messaging. Notifications permissions are all setup.

Thank you.

jolamar commented 1 year ago

could be a lot of things.

  1. Did you name your attributes LiveActivitiesAppAttributes and have a typealias LiveDeliveryData?
  2. Did you add an app group?
  3. does your Info.plist have "Supports Live Activities" to YES
  4. are you testing on a real device? Does that device support live activities?
  5. It sounds like the createActivity function is being called and ID is being generated so it's probably something to do with the Swift code. Maybe provide some snippets of your widget?
ahmdaeyz commented 1 year ago

I have gone through your checklist on other issues so yes I have done all that.

I'm using a real device and it supports live activities.

I am using the generated example which displays a hello world text in cyan background. And as I mentioned it's working on a dummy project.

phuchuynhStrong commented 1 year ago

@ahmdaeyz did you get an activity id after createActivity ?

ahmdaeyz commented 1 year ago

@phuchuynhStrong Yes I did get it.

phuchuynhStrong commented 1 year ago

@ahmdaeyz To be clear, are you talking about live activities on dynamic island or lock screen ?

ahmdaeyz commented 1 year ago

@phuchuynhStrong Both of them. I'm interested in both. I don't have a 14 pro myself but I have tested the example on the simulator and it was actually working.

phuchuynhStrong commented 1 year ago

@ahmdaeyz can you show the code of ActivityConfiguration ? The place where you did the Ui of dynamic island and lock screen

jolamar commented 1 year ago

Have you tried on a real device? What version of iOS? Needs to be at least 16.1

ahmdaeyz commented 1 year ago

@jolamar Yes I'm testing on a real device. The version is 16.3.1 I have set the app group for both the widget and my runner Here's my widget extension in xcode image

@phuchuynhStrong Here is my code using the ActivitiyConfiguration

image

Here is the bundle:

image
jolamar commented 1 year ago

might be good to wrap the WidgetBundle like so:

    if #available(iOS 16.1, *) {
      WatchlistPriceUpdatesLiveActivity()
    }

other than that the widgetconfiguration looks good. Flutter side did you init with appGroupId?

      _liveActivitiesPlugin = LiveActivities();
      _liveActivitiesPlugin.init(appGroupId: "[YOUR APP GROUP]");
ahmdaeyz commented 1 year ago

Okay I will add that. Yes. I initialize the plug-in and then create the activity. And to make sure the problem isn't related to initiation I created a button to create the activity. Still no exceptions. And the id is returned. But no UI on the Lock Screen. Or any sign of a live activity whatsoever.

phuchuynhStrong commented 1 year ago

@ahmdaeyz your code looks fine. Can you make sure Live Activity is enabled in app setting ? (Go to your phone setting -> your app)

ahmdaeyz commented 1 year ago

@phuchuynhStrong It is indeed enabled. I check several times after creating an activity. Can there be some kind of conflict causing the activity not to be shown?

istornz commented 1 year ago

Do you have added the entry in the info.plist file ? https://raw.githubusercontent.com/istornz/live_activities/main/images/tutorial/enable_live_activities.gif

ahmdaeyz commented 1 year ago

@istornz Yes I have added it both to the widget extension and my Runner's info.plist. If I haven't I think an exception will be thrown.

phuchuynhStrong commented 1 year ago

@ahmdaeyz I can't think of any other reason, why it's not working. Make sure you're testing on an iPhone

ahmdaeyz commented 1 year ago

@phuchuynhStrong Not sure if you are being sarcastic. But be assured I've been testing on an iPhone all along :).

phuchuynhStrong commented 1 year ago

@ahmdaeyz no. I made a mistake by testing the live activities on iPad so I just give you another clue to identify your problem

ahmdaeyz commented 1 year ago

@istornz @phuchuynhStrong @jolamar Do you guys have any advice on how I can debug the problem?

jolamar commented 1 year ago

@ahmdaeyz I'd break down the problem and see where it's failing. So take away all the variables you can and start adding them back. So I'd start with removing Flutter aspect of it and just try adding any native live activity to your project. Can follow some of these instructions https://ohdarling88.medium.com/update-dynamic-island-and-live-activity-with-push-notification-38779803c145 if this fails then you know this plugin isn't the problem and there is something in your project that needs addressed.

istornz commented 1 year ago

Hello @ahmdaeyz, did you find the problem?

Arepeel commented 1 year ago

@ahmdaeyz having the same issue, everything enabled..

also enabled remote notification

other extension that i have is one signal extension, which is interesting since you also have a notification extension

testing on a new project working fine, but not working on existing projects

Arepeel commented 1 year ago

@ahmdaeyz @istornz @jolamar

I found a solution, if you have it checked, uncheck "Copy Only When Installing" for Embed App Extension or similar on build phase of main target runner.

Prob need to add that to the readme

lucasvps commented 1 year ago

Does anyone have any solution? I have check what @Arepeel said, but mine wasn't not even checked. So, still looking for some help here @ahmdaeyz any solution?

lucasvps commented 1 year ago

I have found the problem. The problem was the use of images, when I integrate on my project, I've used another images to shown, but they had high resolution compared to the example ones.

Using the resizeRefactor property fix the issue e.g: teamALogo: LiveActivityImageFromAsset('assets/images/psg.png', resizeFactor: 0.3),

fox-avokadik commented 1 year ago

@ahmdaeyz @istornz @jolamar

I also encountered this problem, and as far as I understand, this problem does not depend on specific factors in the iOS module, because I tried the following options: I added live activity to my project, to a newly created (clean) project, and also in a project that attached to the example, I deleted the target that was created and tried creating my own new one - my own new one doesn't work.

The steps were carefully followed to those described in the README.md file. (Also, as far as I understand, this is not a problem of this plugin, since this problem also occurs when we do not use this plugin, but try to integrate from live activity directly into AppDelegate)

soulwawa commented 11 months ago

hi, I was using version 1.7.5, and that version worked well, but when I updated it to 1.9.0, it doesn't work. I don't know why yet 1.9.0 Is there no problem?

soulwawa commented 11 months ago

hi, I was using version 1.7.5, and that version worked well, but when I updated it to 1.9.0, it doesn't work. I don't know why yet 1.9.0 Is there no problem?

1.8.0 worked well. Test results indicate that a new installation should not be made in the simulator My guess is that 1.9.0 is problematic

istornz commented 11 months ago

Hi @soulwawa, could you try to implement multiple notification key system like said on the doc? https://github.com/istornz/flutter_live_activities/tree/main#multiple-notifications-

This is just to test if this is the problem or not 👍

soulwawa commented 11 months ago

@istornz It works well if you follow your guide. I'm worried that there are people who make the same mistake as me.

Thank you for your kind reply.

istornz commented 11 months ago

@soulwawa Thanks for your reply, I will add breaking change in the README.md & CHANGELOG.md file.

This fix was intented to allow multiple notification to work 👍

sbergmair commented 9 months ago

For clarification and anybody who debugged as long as we did without success:

While migrating to the new version, we forgot to read the instructions carefully. In our case following code (mentioned in the Readme) did it:

extension LiveActivitiesAppAttributes {
  func prefixedKey(_ key: String) -> String {
    return "\(id)_\(key)"
  }
}

This is used to extract the params:

ActivityConfiguration(for: LiveActivitiesAppAttributes.self) { context in
      // create your live activity widget extension here
      // to access Flutter properties:
      let myVariableFromFlutter = sharedDefault.string(forKey: context.attributes.prefixedKey("myVariableFromFlutter"))!

      // [...]
}

We did not get it, because there is no error if parsing the arguments fails. Therefore, we got an ID after calling createActivity() on flutter side.

JacobSchantz commented 8 months ago

I was dealing with this issue as well. I found in some cases all you need to do is turn your device all the way off and turn it back on.