<div dir="ltr">My first instinct is to use the service resolver to pick the right interface.<div><br></div><div>For example in the fh-xamarin-sdk push APIs we have a interface IPush which is accessed as follows</div><div><br></div><div>```</div><div>

<span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:pre;word-spacing:0px;background-color:rgb(255,251,221);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">ServiceFinder.Resolve&lt;IPush&gt;().Register(HandleNotification);</span>

<br></div><div>```</div><div><br></div><div>ServiceFinder is responsible for determining which implementation is currently linked in the app.  What this means is that when you build xamarin forms for iOS you depend on the iOS implementations in your build configuration and likewise for Android.  This is probably easiest if you have an Android and iOS forms project which bootstrap the whole thing.</div><div><br></div><div>Links</div><div><br></div><div>IPush Shared code : <a href="https://github.com/feedhenry/fh-dotnet-sdk/tree/master/FHSDK/Services/Network">https://github.com/feedhenry/fh-dotnet-sdk/tree/master/FHSDK/Services/Network</a></div><div>                                  <a href="https://github.com/feedhenry/fh-dotnet-sdk/blob/master/FHSDKPortable/Services/Network/Push.cs">https://github.com/feedhenry/fh-dotnet-sdk/blob/master/FHSDKPortable/Services/Network/Push.cs</a></div><div>Android IPush impl : <a href="https://github.com/feedhenry/fh-dotnet-sdk/tree/master/FHXamarinAndroidSDK/Services/Network">https://github.com/feedhenry/fh-dotnet-sdk/tree/master/FHXamarinAndroidSDK/Services/Network</a></div><div>Ios push impl          : <a href="https://github.com/feedhenry/fh-dotnet-sdk/tree/master/FHXamarinIOSSDK/Services/Network">https://github.com/feedhenry/fh-dotnet-sdk/tree/master/FHXamarinIOSSDK/Services/Network</a></div><div><br></div><div>Example Xamarin apps :<a href="https://github.com/feedhenry-templates/pushstarter-xamarin-app">https://github.com/feedhenry-templates/pushstarter-xamarin-app</a></div><div><br></div><div>I know these aren&#39;t forms apps and that creates a bit of a roadblock to your question, but I think Xamarin is meant to have a bunch of small platform specific projects with a few common ui projects.  There are a few videos where MS talks about developing Xamarin apps that I can hunt down if people are interested.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 20, 2018 at 8:59 AM, Vojtech Sazel <span dir="ltr">&lt;<a href="mailto:vsazel@redhat.com" target="_blank">vsazel@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>we encountered a problem with Aiden and Massimo with the underlying architecture of the multiplatform project in Xamarin. <br><br>We need to have Auth service module accessible from application. But module has some platform specific implementations we need to get.<br><br></div><div>1) Suppose we have some class <font face="monospace, monospace">Auth</font> implementing <font face="monospace, monospace">IServiceModule</font>. We would have it implemented only using platform-independent. So we can simply do <br><pre style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background:rgb(255,255,255)">MobileCore<span style="color:rgb(128,128,48)">.</span>Instance<span style="color:rgb(128,128,48)">.</span>GetInstanc<wbr>e<span style="color:rgb(128,128,48)">&lt;</span>Auth<span style="color:rgb(128,128,48)">&gt;</span><span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span></pre>2) But now we need to have some platform specific stuff done in the module, so we create <font face="monospace, monospace">AuthAndroid</font><font face="arial, helvetica, sans-serif"> and </font><font face="monospace, monospace">AuthIOS </font><font face="arial, helvetica, sans-serif">extending </font><font face="monospace, monospace">Auth</font><font face="arial, helvetica, sans-serif"> (which is now abstract) in platform specific projects.</font></div><div><br clear="all"><div>In ordinary pure Android (or iOS respectively) app we can do:</div><div><pre style="font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;color:rgb(0,0,0);background:rgb(255,255,255)">MobileCore<span style="color:rgb(128,128,48)">.</span>Instance<span style="color:rgb(128,128,48)">.</span>GetInstanc<wbr>e<span style="color:rgb(128,128,48)">&lt;</span>AuthAndroid<span style="color:rgb(128,128,48)">&gt;</span><span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span></pre>3) But we can&#39;t do that with Xamarin.Forms app where stuff is in platform independent project.<br><br>We can utilize <font face="monospace, monospace">DependencyService </font><font face="arial, helvetica, sans-serif">in Xamarin.Forms app project or create separate Xamarin.Forms project with </font><font face="monospace, monospace">Auth</font><font face="arial, helvetica, sans-serif">, but it seems that code won&#39;t be very pretty in this case. </font></div><div><font face="arial, helvetica, sans-serif"><br>What can we do to solve this problem?<br>I think we can debate it further after todays ST1 standup.</font></div><div><br></div>-- <br><div class="m_-3681458155341705574gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-weight:bold;margin:0px;padding:0px;font-size:14px;text-transform:uppercase"><span>VOJTĚCH</span> <span>SÁZEL</span></p><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px;margin:0px 0px 4px;text-transform:uppercase"><span>SENIOR SOFTWARE ENGINEER, RED HAT MOBILE</span></p><p style="font-family:overpass,sans-serif;margin:0px;font-size:10px;color:rgb(153,153,153)"><a href="https://www.redhat.com/" style="color:rgb(0,136,206);margin:0px" target="_blank">Red Hat <span><br><br></span></a></p><span style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"><p style="font-size:10px;margin:0px;color:rgb(153,153,153)">Remote Czech Republic</p></span><span style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"></span><p style="font-family:overpass,sans-serif;margin:0px 0px 6px;font-size:10px;color:rgb(153,153,153)"><span style="margin:0px;padding:0px"><a href="mailto:vsazel@redhat.com" style="color:rgb(0,136,206);margin:0px" target="_blank">vsazel@redhat.com</a>   </span> <span>IM: <span>vsazel</span></span></p><table border="0" style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"><tbody><tr><td width="100px"><a href="https://red.ht/sig" target="_blank"><img width="90" height="auto"></a></td></tr></tbody></table></div></div></div></div></div></div>
</div></div>
</blockquote></div><br></div>