# Help with my First Foreign Code Module

**URL:** https://forums.fusetools.com/t/help-with-my-first-foreign-code-module/1474
**Category:** General
**Created:** [August 8, 2016, 4:44pm UTC](https://forums.fusetools.com/t/help-with-my-first-foreign-code-module/1474 "2016-08-08T16:44:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![raphael.godoi](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/raphael.godoi/32/312_2.png) [@raphael.godoi](https://forums.fusetools.com/u/raphael.godoi)
#### Post date: [August 8, 2016, 4:44pm UTC](https://forums.fusetools.com/t/help-with-my-first-foreign-code-module/1474/1 "2016-08-08T16:44:16Z")

</div>

I’m using the InterApp methods to open waze or google maps from my app, but, i need to check if that ap exists before calling it, so thats the reason of this module.

when I try to preview, i got the message: `checkUrl is not on this scope, do you forgot to require a module?`

that’s my code:

```auto
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;

[UXGlobalModule]
public class UrlModule : NativeModule
{
    static readonly UrlModule _instance;

    public UrlModule()
    {
        // Make sure we're only initializing the module once
        if(_instance != null) return;

        _instance = this;
        Resource.SetGlobalKey(_instance, "UrlModule");
        AddMember(new NativeFunction("canOpenUrl", (NativeCallback)canOpenUrl));
    }

    [Foreign(Language.ObjC)]
    public static extern(iOS) bool checkUrl(string url)
    @{
        NSString* appURL = [NSString stringWithFormat:@"%@", url];
        BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:appUrl]];
        return canOpenURL;
    @}

    static object canOpenUrl(Context c, object[] args)
    {
        return checkUrl("maps://");
    }

}

```

thanks in advance.

---

<div class="post-metadata">

### Author: ![Max\_Graey](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/max_graey/32/347_2.png) [@Max\_Graey](https://forums.fusetools.com/u/Max_Graey)
#### Post date: [August 8, 2016, 8:47pm UTC](https://forums.fusetools.com/t/help-with-my-first-foreign-code-module/1474/2 "2016-08-08T20:47:04Z")

</div>

for working in Preview you should implement this:

```auto
public static extern(!(iOS || Android)) bool checkUrl(string url) {
    return /some code on Uno's Runtime/
}

```

---

<div class="post-metadata">

### Author: ![raphael.godoi](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/raphael.godoi/32/312_2.png) [@raphael.godoi](https://forums.fusetools.com/u/raphael.godoi)
#### Post date: [August 8, 2016, 8:47pm UTC](https://forums.fusetools.com/t/help-with-my-first-foreign-code-module/1474/3 "2016-08-08T20:47:59Z")

</div>

ok, i’ll test it.
