Xamarin.Forms app with iOS Today Widget

roycornelissenroycornelissen USInsider, University, Developer Group Leader ✭✭

I'm working on a Xamarin.Forms app and I'm trying to add a Today Widget for iOS. I've added the Today Extension project, set the reference from my iOS project and made sure that the bundle ID's are correct (com.company.appname and com.company.appname.extensionname). Still the widget is not showing up in the Notification Center (it's not in the list of extensions to add). When I create a blank iOS project (Single View app) and add a Today Extension to it, it works like a charm.

Is the fact that this is a Forms app a problem? I know one of the requirements is that the container app must have at least one screen, so I created a dummy Storyboard and set the Main Interface in Info.plist to that storyboard, but to no avail.

What could I be missing?

Best Answer

Answers

  • GeraldVersluisGeraldVersluis NLUniversity ✭✭✭✭
    edited September 2016

    Did you do it from Visual Studio or Xamarin Studio?

    I just tried with Xamarin Studio (6.1 build 5436, beta track) and when I just add a Today Extension project without further configuration other than the one in the wizard it works out of the box!

    First I created a Forms project based on a PCL then I just added the Extension project by Solution > Add > Add New Project and then picked the Today Extension

    After that you can link it automagically to the iOS project already in your solution

    And running in the Simulator just shows it in the Today screen and I can add it from there, no problem!

    To further trace the issue here are my info.plist of the app project (WidgetTest)

    and the Extension project (Widget, I agree, naming could be improved.. :wink: )

  • roycornelissenroycornelissen USInsider, University, Developer Group Leader ✭✭

    Yeah I did the exact same thing in the Forms app. Reference and info.plist look ok. Also tried the same as you via a blank app and that worked out of the box.

    I'm using Xamarin Studio.

    I suspect that Forms is in the way somehow, but that's just a hunch.

  • roycornelissenroycornelissen USInsider, University, Developer Group Leader ✭✭
    edited September 2016

    ... Hm a blank Forms app with the correct deployment targets set does seem to work. Something is wrong with my app apparently.

  • TamasMatraiTamasMatrai HUUniversity ✭✭

    I have the same issue roy.

    Did you find any solution?

  • roycornelissenroycornelissen USInsider, University, Developer Group Leader ✭✭

    @TamasMatrai yes, see the marked answer

  • TamasMatraiTamasMatrai HUUniversity ✭✭
    edited September 2016

    @roycornelissen Thanks very much, I'll try it. Here is the opportunity for me to move my solution to VS from XS.

  • roycornelissenroycornelissen USInsider, University, Developer Group Leader ✭✭

    @TamasMatrai did it work for you?

  • TamasMatraiTamasMatrai HUUniversity ✭✭
    edited September 2016

    @roycornelissen No, it was a mission impossible for me to build the project in Visual Studio. I spent several hours with it, updated everything, but could not build. Typical Xamarin. I go on with my project in Xamarin Studio, so there won't be today extension for this project. :confused: Anyway, it worked from command line, but I won't use this uncomfortable solution just for this. It is unaccaptable for me, it would be ok for an opensource like project, but not for a Microsoft related 'professional' one. I've had enough of these kind of problems with Xamarin. Thanks for your help and support! :smile:

  • anjukadadianjukadadi INMember ✭✭

    what are the methods which can communicate between main app and widget in xamarin forms??

  • roycornelissenroycornelissen USInsider, University, Developer Group Leader ✭✭

    @anjukadadi Not many options, sadly... You have to resort to shared data stored on disk (in a shared container) or e.g. in de NSUserDefaults, but you have to do some extra things to make sure that they are allowed to share these NSUserDefaults. I've resorted to storing the data.

    Here's a guide for app <> extension communication: http://www.glimsoft.com/06/28/ios-8-today-extension-tutorial/

    And another thread about this on this forum: https://forums.xamarin.com/discussion/24921/how-to-update-data-to-a-today-extension-widget-from-the-containing-app

Sign In or Register to comment.