     timeout ?= null
     @handshakeTimeout ?= DEFAULT_HANDSHAKE_TIMEOUT_MS
     @isListening = false
+    @isLegacy = false # TODO: remove when native apps are updated
     @hasParent = window? and window.self isnt window.top
     @parent = window?.parent
 

    if navigator.serviceWorker
      # only use service workers if current page has one
      @ready = navigator.serviceWorker.getRegistrations()
      .then (registrations) =>
        if registrations.length
          @sw = new RPCClient({

        throw new Error 'Method not found'
      return fn.apply null, params

    # TODO: clean this up
    @ready.then =>
      if @hasParent
        parentError = null
        @validation
        .then =>
          if not @isLegacy and @parentsRegisteredMethods.indexOf(method) is -1
            return localMethod method, params
          else
            @client.call method, params
            .catch (err) =>
              parentError = err
              if @sw
                @sw.call method, params
                .catch ->
                  return localMethod method, params
              else
                return localMethod method, params
            .catch (err) ->
              if err.message is 'Method not found' and parentError isnt null
                throw parentError
              else
                throw err
      else
        new Promise (resolve) =>
          if @sw
            resolve(
              @swValidation.then =>
                if @parentsRegisteredMethods.indexOf(method) is -1
                  return localMethod method, params
                else
                  @sw.call(method, params)
                  .catch (err) ->
                    return localMethod method, params
            )
          else
            resolve localMethod(method, params)
