Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
React-Native Module in Swift with async function throws is not a recognized Objective-C method

I am trying to export a swift module according to react-native's documentation but I run into the following error when I try to call this function in my javascript file. I believe the issue has to do with calling an async method in my swift code. So I'm not sure how to export and call an async method from my swift file when creating a native module in react-native.

exception error object-c methor

Here is the AppleMusicAuth.swift file that contains the async method I'm trying to export

//
//  AppleMusicAuth.swift
//
//
//

import Foundation
import MusicKit

@available(iOS 15.0, *)
@objc(AppleMusicAuth)
class AppleMusicAuth: NSObject {

  @objc
  func getAuthStatus() async -> Void {
    let response = await MusicAuthorization.request()
    print(response)
  }
}

Along with my AppleMusicAuth.m file that makes use of RCT_EXTERN_METHOD method for exporting the module to my JS application

//
//  AppleMusicAuth.m
//
//
//

#import <Foundation/Foundation.h>

#import <React/RCTBridgeModule.h>


@interface RCT_EXTERN_MODULE(AppleMusicAuth, NSObject)

RCT_EXTERN_METHOD(getAuthStatus)

@end

And the Javascript files that import and call the module and method for use

import { NativeModules } from 'react-native';
const { AppleMusicAuth } = NativeModules;
export default AppleMusicAuth;
import React from 'react';
import {Button} from 'react-native';
import AppleMusicAuth from '../nativeModules/AppleMusicAuth';

type Props = {};

const App: React.FC<Props> = () => {
  return (
        <Button
          onPress={() => {
            AppleMusicAuth.getAuthStatus();
          }}
          title="Button"
          color="#841584"
        />
  );
};

export default App;

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda