apple M1에서 React Native 관련 자료모음

버들비·2021년 11월 25일
0

nodejs 서버에서 푸시 알림 보내기

상단에서 firebase admin 불러온 후 init

var admin = require("firebase-admin");

var serviceAccount = require("./serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});
const token = "fcm 에서 getToken() 함수를 통해 얻을수 있는 토큰 스트링"
const message = {
    notification: {
      body: '본문임',
      title: 'FCM Notification',
    },
    token: token,
    apns: {
      payload: {
        aps: {
          contentAvailable: true,
        },
      },

    },
  };
  admin
    .messaging()
    .send(message).then(response => {
      console.log('Successfully sent message:', response);
      return res.json({ message: "성공" })
    })
    .catch(error => {
      console.log('Error sending message:', error);
      return res.status(500).json({ message: "실패" })
    });;

안드로이드 실기에서 getFCM 함수 호출시 생기는 문제(Android: FCM java.io.IOException: SERVICE_NOT_AVAILABLE error on some devices)

안드로이드 실제 기기를 노트북과 같은 와이파이에 연결하니 해결.
https://stackoverflow.com/questions/50208426/android-fcm-java-io-ioexception-service-not-available-error-on-some-devices

FCM 으로 푸쉬알림 기능

https://yangeok.github.io/reactnative/2020/06/07/fcm-push-notification.html

M1, pod 문제

파이어베이스 관련 패키지 설치로 인한 문제

에러 로그

Error

LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi.rb:5:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:78:in `deprecated_local_podspecs'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:60:in `preheat_existing_files'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:257:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:141:in `block (3 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:140:in `block (2 levels) in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:139:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:139:in `block in update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:137:in `open'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:137:in `update'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command/repo/update.rb:23:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=dlopen%28%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle%2C+0x0009%29%3A+missing+compatible+arch+in+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle+-+%2FLibrary%2FRuby%2FGems%2F2.6.0%2Fgems%2Fffi-1.15.4%2Flib%2Fffi_c.bundle&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...

해결법

ios 폴더에서
arch -x86_64 rm -rf Podfile.lock
arch -x86_64 pod install --repo-update

그리고 문제가 생긴다면 일단 무조건 로제타 터미널에서 실행해보자. 또한 기존에 돌아가던 node 가 kill 돼 있지 않아서 오류가 생길수도 있으니 한번 체크할것

안드로이드 빌드에서 Plugin with id 'com.google.gms.google-services' not found 문제

해결법

android 폴더에 있는 build.gradle 파일에 dependencies 항목에 lasspath 'com.google.gms:google-services:4.3.2' 를 추가. Do not place your application dependencies here; 라고 적혀있지만 무시하자.

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        classpath 'com.google.gms:google-services:4.3.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

0개의 댓글