가장 잘 쓰고 있는 하나중에 손에 꼽힌다.

 

안드로이드에 있는 Toast를 똑같이 구현해본거다. 

원래는 상 | 중 | 하 단으로 선택해서 구현을 했지만, 딱히 상 | 하 단을 이용하지 않아 지워버렸다!

 

써보고 싶은 사람은 써보고 개선할점이 있으면 알려주기 바랍니다.

아니면 개선해서 알려주세요 ㅎㅎ

 

xib 파일은 다운받아서 써보세요. 쓰는 방법은

 

Toast.showToastMessage(message: "")

let kTOAST_DURATION_VALUE: TimeInterval = 0.5
let kTOAST_HEIGHT_VALUE: CGFloat = 80.0
let kTOAST_WIDTH_RATE_VALUE: CGFloat = 0.9

class Toast: UIView {
    
    @IBOutlet weak var msg_lb: UILabel!

    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    class func showToastMessage(message: String) {
        if let topVC = Utils.topViewController() {
            let name = String(describing: Toast.self)
            guard let loadedNib = Bundle.main.loadNibNamed(name, owner: self, options: nil) else { return }
            guard let toast = loadedNib.first as? Toast else { return }
            toast.msg_lb.text = message
            toast.show(activeView: topVC.view, message: message)
            
            toast.translatesAutoresizingMaskIntoConstraints = false
            toast.centerXAnchor.constraint(equalTo:topVC.view.centerXAnchor).isActive = true
            toast.centerYAnchor.constraint(equalTo:topVC.view.centerYAnchor).isActive = true
            toast.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.size.width * kTOAST_WIDTH_RATE_VALUE).isActive = true
        }
    }
    
    func show(activeView :UIView, message:String) {
        self.msg_lb.layer.cornerRadius = 5
        self.msg_lb.text = message
        
        self.alpha = 0
        self.isUserInteractionEnabled = false
        
        activeView.addSubview(self)
        
        UIView.animate(withDuration: kTOAST_DURATION_VALUE, delay: 0, options: .curveEaseIn, animations: {
            self.alpha = 1.0
        }) { (finished) in
            self.isUserInteractionEnabled = true
            UIView.animate(withDuration: kTOAST_DURATION_VALUE, delay: 1.0, options: .curveEaseIn, animations: {
                self.alpha = 0.0
            }) { (finished) in
                self.removeFromSuperview()
            }
        }
    }
}

 

Toast.swift
0.00MB
Toast.xib
0.00MB

 

 


 

'[ 자기개발 ] > [ Swift ]' 카테고리의 다른 글

Alert.swift  (0) 2020.11.19
UIColor+Extension.swift  (0) 2020.11.19

Photo Editing

A Photo Editing extension lets users edit a photo or video within the Photos app. After users confirm the changes they make in a Photo Editing extension, the adjusted content is available in Photos. Photos always keeps the original version of the content, too, so that users can revert the changes they make in an extension.

BEFORE YOU BEGIN

Make sure that the Photo Editing extension point is appropriate for the functionality you want to provide. A Photo Editing extension should make it easy for users to make quick, targeted adjustments to a photo or video without requiring too much user interaction. If you want to enable a more generic task or help users share photos and videos with others, the Photo Editing extension point is not the right choice.

To learn about other types of app extensions you can create, see Table 1-1.

Understand How a Photo Editing Extension Works with Photos

To support a consistent editing experience, Photos keeps multiple versions of each media asset’s image or video data, in addition to adjustment data, which describes past edits made to the asset. For each asset, Photos stores the original version, the current version (which includes the most recent adjustments), and the set of adjustments that were applied to the original version to create the current version.

When a user chooses a Photo Editing extension, Photos asks the extension if it can read the adjustment data. If the app extension supports the adjustment data, Photos provides the original version of the asset as input to the editing session. After the extension reads the adjustment data and reconstructs the past edits, it can allow users to alter or revert past edits or add new edits. For example, if the adjustment data describes filters applied to a photo, the extension reapplies those filters to the original asset and can let users change filter parameters, add new filters, or remove filters.

If the extension doesn’t support an asset’s adjustment data, Photos provides the current version of the asset as input to the editing session. Because the current version contains the rendered output of all past edits, the extension can let users apply new edits to the asset but not alter or revert past edits.

IMPORTANT

Photos does not store a current version of video assets. If your extension can’t read a video asset’s adjustment data, it must work with the original version of the video, overwriting past edits.

When a user finishes using a Photo Editing extension, the extension returns the edited asset and the adjustment data.

Use the Xcode Photo Editing Template

The Xcode Photo Editing template provides default header and implementation files for the principal view controller class (called PhotoEditingViewController), an Info.plist file, and an interface file (that is, a storyboard file).

IMPORTANT

Embed no more than one Photo Editing extension for each media type (photo, video, or Live Photo) in a containing app. The Photos app displays to the user, at most, one extension of each type from a given containing app. In general, it’s best when one Photo Editing extension handles multiple media types.

By default, the Photo Editing template supplies the following Info.plist keys and values:

  1. <key>NSExtension</key>
  2. <dict>
  3. <key>NSExtensionAttributes</key>
  4. <dict>
  5. <key>PHSupportedMediaTypes</key>
  6. <array>
  7. <string>Image</string>
  8. </array>
  9. </dict>
  10. <key>NSExtensionMainStoryboard</key>
  11. <string>MainInterface</string>
  12. <key>NSExtensionPointIdentifier</key>
  13. <string>com.apple.photo-editing</string>
  14. </dict>

In particular, make sure that the PHSupportedMediaTypes array specifies the types of media assets your app extension can edit. The default value is Image, but you can also use Video and LivePhoto.

Design the UI

IMPORTANT

For best results, use Auto Layout to design the view of a Photo Editing extension.

In iOS, your app extension’s view must support a full-screen presentation on devices of different sizes, as well as Slide Over and Split View presentations on iPad. In macOS, your app extension’s view occupies the entire Photos window, which is resizable and supports full-screen presentation.

The Photos app displays a Photo Editing extension with a navigation bar in iOS or a combined title bar and toolbar in macOS. Don’t create a navigation-based UI, and avoid stacking additional top-oriented toolbars in your app extension.

Photos automatically displays your app extension’s view so that it occupies the full height of the screen (iOS) or window (macOS), including the area behind the navigation bar or title bar. If you want your content view to appear below the bar, and not behind it, use the view’s top layout guide appropriately.

It’s best when a Photo Editing extension lets users preview the results of their edits. Giving users a preview while they’re still using your app extension means that they can get the effect they want without repeatedly exiting and reentering the extension.

Because users are likely to spend time editing a photo or movie in your app extension, you don’t want them to lose their work if they accidentally choose Cancel. To improve the user experience, be sure to implement the shouldShowCancelConfirmation method in your view controller, returning YES if there are unsaved changes. When this method returns YES, Photos displays confirmation UI so that users can confirm if they really want to cancel their changes.

Implement Your Extension

Users get access to Photo Editing extensions in the Photos app. When a user chooses your app extension, display a view that provides a custom editing interface. To present this view, use a view controller that adopts the PHContentEditingController protocol.

When a user chooses your app extension, Photos provides the asset being edited to your extension’s view controller in the form of a PHContentEditingInput object. For photo and video assets, you use this object to access the asset’s image or video data to perform your editing. When the user chooses to end editing, Photos asks your app extension’s view controller for a PHContentEditingOutput object, which you use to provide the edited asset data.

NOTE

To provide responsive performance during photo editing, use the content editing input’s displaySizeImage property to preview edits. When the user chooses to end editing, apply your edits to the full-size image using the fullSizeImageURL property.

When your app extension works with Live Photo assets, it doesn’t access the asset’s underlying image and video resources directly. Instead, you create a PHLivePhotoEditingContext object from the provided content editing input, and use the methods that class provides to perform and preview edits.

If your app extension edits video assets, see the AVVideoComposition videoCompositionWithAsset:applyingCIFiltersWithHandler: method for an easy way to apply image-processing filters.

For example code illustrating how to edit all asset media types, download the Sample Photo Editing Extension sample code project.

Handling Memory Constraints

Because a Photo Editing extension often needs to work with large high-resolution images and videos, the extension is likely to experience memory pressures when running on a device. It’s recommended that you examine your existing image-processing code and make sure that it performs to a high standard before you use it in your app extension.

Testing a Photo Editing Extension

Avoid making assumptions about the media formats that your app extension may receive. Be sure to test your filtering and other image-processing code with a wide range of media formats; don’t just test with content from the device camera.

To learn about debugging app extensions in general, see Debug, Profile, and Test Your App Extension.

 

 

스크랩 : https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/Photos.html

 

App Extension Programming Guide: Photo Editing

App Extension Programming Guide

developer.apple.com

 

Download Sample Code

https://developer.apple.com/library/archive/samplecode/SamplePhotoEditingExtension/Introduction/Intro.html#//apple_ref/doc/uid/TP40014576

Navigation Bar and Toolbar Icon Size

Use the following sizes for guidance when preparing custom navigation bar and toolbar icons, but adjust as needed to create balance.

Target sizesMaximum sizes

72px × 72px (24pt × 24pt @3x) 84px × 84px (28pt × 28pt @3x)
48px × 48px (24pt × 24pt @2x) 56px × 56px (28pt × 28pt @2x)

Tab Bar Icon Size

In portrait orientation, tab bar icons appear above tab titles. In landscape orientation, the icons and titles appear side-by-side. Depending on the device and orientation, the system displays either a regular or compact tab bar. Your app should include custom tab bar icons for both sizes.

Target width and height (circular glyphs)

Regular tab barsCompact tab bars

75px × 75px (25pt × 25pt @3x) 54px × 54px (18pt × 18pt @3x)
50px × 50px (25pt × 25pt @2x) 36px × 36px (18pt × 18pt @2x)

Target width and height (square glyphs)

Regular tab barsCompact tab bars

69px × 69px (23pt × 23pt @3x) 51px × 51px (17pt × 17pt @3x)
46px × 46px (23pt × 23pt @2x) 34px × 34px (17pt × 17pt @2x)

Target width (wide glyphs)

Regular tab barsCompact tab bars

93px (31pt @3x) 69px (23pt @3x)
62px (31pt @2x) 46px (23pt @2x)

Target height (tall glyphs)

Regular tab barsCompact tab bars

84px (28pt @3x) 60px (20pt @3x)
56px (28pt @2x) 40px (20pt @2x)

 

 

스크랩 : https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/custom-icons/

현재 사용 하고 있는 POD를 정리 해 보기.

 

머 상황마다 다르겠지만 지금은 간단하게 사용할 수 있는 POD 를 나열해보자.

 

Objective-c를 사용는데 요세는 Objective-c를 찾기가 어렵다 ㅠ.ㅠ

 

 

 

pod 'ViewDeck', '~> 3.0'

https://github.com/ViewDeck/ViewDeck

 

ViewDeck/ViewDeck

An implementation of the sliding menu found in various iOS apps. - ViewDeck/ViewDeck

github.com

pod 'EKKeyboardAvoiding'

https://github.com/kirpichenko/EKKeyboardAvoiding

 

kirpichenko/EKKeyboardAvoiding

It's an universal solution for keyboard avoiding for iOS that allows automatically change content inset of UIScrollView and it's subclasses. When keyboard is presented you will be able to s...

github.com

 

pod 'Firebase/Core'

pod 'Firebase/Messaging'

 

pod 'FBSDKCoreKit', '~> 4.38.0'

pod 'FBSDKLoginKit', '~> 4.38.0'

 

pod 'youtube-ios-player-helper'

 

pod 'naveridlogin-sdk-ios'

pod 'IGRFastFilterView'

pod 'NMapsMap'

 

pod 'PPBadgeView'

https://github.com/jkpang/PPBadgeView

 

jkpang/PPBadgeView

iOS Custom Badge, Support UIView, UITabBarItem, UIBarButtonItem ,Support Objective-C/Swift; iOS自定义Badge组件, 支持UIView, UITabBarItem, UIBarButtonItem, 支持Objective-C/Swift - jkpang/PPBadgeView

github.com

pod 'BEMCheckBox'

https://github.com/Boris-Em/BEMCheckBox

 

Boris-Em/BEMCheckBox

Tasteful Checkbox for iOS. (Check box). Contribute to Boris-Em/BEMCheckBox development by creating an account on GitHub.

github.com

pod 'MarqueeLabel'

https://github.com/cbpowell/MarqueeLabel

 

cbpowell/MarqueeLabel

A drop-in replacement for UILabel, which automatically adds a scrolling marquee effect when the label's text does not fit inside the specified frame - cbpowell/MarqueeLabel

github.com

pod 'FSPagerView'

https://github.com/WenchaoD/FSPagerView

 

WenchaoD/FSPagerView

FSPagerView is an elegant Screen Slide Library. It is extremely helpful for making Banner View、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. - WenchaoD/FSPagerView

github.com

 

 

 

 

 

 

 

아주 주관적이고 막혔을떄 정리하는거라 태글걸지 마시기 바랍니다.

 

우선 최근까지 pod `NMapsMap' 만 install 해주면 아주 깔끔하게 사용할 수 있었다.

그래서 그렇게 사용하고 있었는데. 다른 프로젝트에 적용하려고 하니.. 이런 SSi... 에러가 에러가...

 

0. IB Designables: Failed to render and update auto layout status.

0. Undefined symbols for architecture x86_64 _objc_class_$

 

라는 에러를 계속 내뿜는게 아닌가.

 

그래서 이걸 어떻게 해결해야하나.. 구글링을 계속 하는데.. 별에 별걸 다 해본것 같다.


Build Setting -> BitCode 를 검색해 NO로 바꿔주라고해서 바꿔줬는데도 똑같고.

Framework Path가 잘못되어있나 강제로도 넣어봤고.

Other Path로 설정해봤고.

새로운 프로젝트를 열어서 다시 해보고.

혹시 Pod에 문제가있나해서 Pod도 지웠다가 다시 설치해보고.

컴퓨터가 문제인가 컴퓨터를 바꿔서도 해보고


.

아... 그런데 똑같은 문제가 계속 발생...

 

결국. Naver Cloud Platform 홈페이지 들어가서 문의글을 딱 남기는데...

바로 해결... ㅋㅋ

 

내가 멍청했던거지.. 물어보면 끝나는걸...

혹시 안되서 검색하는 분들을 위해 이걸을 남겨본다 ㅋㅋㅋ

 

이글 본사람들은 문의하길 바라고.. 우선 내가 해결했던 방법을 설명해본다.

 


 

간단 명료하게 결론만 말하자면 NMapsMap이 용량이 커지면서 Git-lfs 를 이용하게 되었다는것.

그래서 Git-lfs를 설치를 해줘야한다는 것.

 

https://github.com/navermaps/ios-map-sdk

NaverMap github에 들어가서 CocoaPods구성 확인

 

1. 기존에 사용중이던 Pods 폴더를 삭제.

2. 터미널창에 pod cache clean NMapsMap 실행

3. git-lfs 설치

3-1. 터미널창에 sudo gem install cocoapods 실행

3-2. brew install git-lfs 실행 [ https://brew.sh/ ]

   * not found ... 에러가 나는 분들은 Homebrew 가 없어서 그러니 

   /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

   위 명령어를 그대로 복사해서 실행.

   * brew 설치가 끝나고 확인하기위해 brew doctor 실행

   * brew doctor 실행이 끝나면 brew install git-lfs 실행

3-3. git-lfs install 실행 <- 나는 이건 실행안한것 같다.

4. 프로젝트 폴더로 이동 cd /path/your-project

   * 간혹 그대로 path/your-project로 control+c | control+v 하는 사람 있는데 그러지말고

   * 1. 터미널에 cd 입력하고 한칸띄고

   * 2. 당신의 프로젝트가 있는 Finder를 열어서 해당 폴터를 끌어다가 터미널에 넣으면 경로가 자동으로 입력이 되고

   * 3. 그뒤! 엔터를 누르면 됩니다.

5. 프로젝트에있는 Pods 폴더와 캐쉬를 지웠으니 터미널에 pod install --repo-update 실행

6. 업데이트가 다 되면 프로젝트 실행 후 클린하고 빌드하면 Build Success를 볼수 있다.

 


 

여기까지가 내가 애먹었던 부분을 풀어논것이다.

 

먼가 이상하고 애매하고 잘안되는 사람은 리뷰 달지마시고 찾아보는 것을 추천한다.

 

 

 

 

 

 

 

 

 

 


이번에 어플 업데이트 하면서 아주 곤욕을 치룬 코드이다.


보면 아주 간단하지만. 이것때문에 일주일간을 몸져누울뻔했다.



코드는 아래와 같이 간단하게 되어 있다.



NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];

NSString* bundleId = infoDictionary[@"CFBundleIdentifier"];

NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", bundleId]];

NSData* data = [NSData dataWithContentsOfURL:url];

NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

     

if ([lookup[@"resultCount"] integerValue] >= 1){

     NSString* appStoreVersion = lookup[@"results"][0][@"version"];

     NSString* currentVersion = infoDictionary[@"CFBundleVersion"];

         

if (![appStoreVersion isEqualToString:currentVersion]) {

return NO;

}

}

return YES;



위 코드는 일반적으로 구글에서 검색해보면 나오는 코드이다.


여기서 핵심은 


1. [[NSBundle mainBundle] infoDictionary];

2. http://itunes.apple.com/lookup? 에서 받아오는 데이터와 주소


1번 같은경우는 우리가 만든 프로젝트의 BundleId를  가져오는 것이다.

2번은 해당 주소를 호출해 우리가 원하는 데이터를 가져오는 것이다.




그런데 이번에 이 부분을 업데이트 하면서 아주 곤욕을 치룬 일을 공유해본다.



이번에 대대적인 업데이트를 하면서


해당 코드를 추가하고 버전이 다르면 업데이트 팝업창을 호출하는 형식을 만들었다.



그런데!! 이게 왠말인가




 문제점 발견



출시가 되어도 업데이트 팝업창이 나오지 않는 현상을 발견했다.


처음에는 출시되고 동기화가 되는데에 좀 걸릴 수 있지 라고 생각하고 기다려보았다.

보통 출시되고 30분 ~ 2시간 이내에 동기화가 된다.


그래 마냥 기다리면 동기화가 되겠지하고 손놓고 기다리는데 퇴근할때까지 업데이트가 안되는걸 확인하고 


부랴부랴 해당 로그를 확인해본보았다.





현재 버전 : 2.0  

스토어에 업데이트 되는 버전 : 2.1


우선 테스트 한 순서


1. http://itunes.apple.com/lookup?bundleId="com.crazybrain.appstoreversion"

2. http://itunes.apple.com/lookup?id="12341234"

3. http://itunes.apple.com/lookup?bundleId="com.crazybrain.appstoreversion"&id=12341234

4. Mobile 에서 http://itunes.apple.com/lookup?id="12341234" 주소 호출

= Chrome 어플 에서 주소 호출

= Samsung Browser 어플 에서 주소 호출

= Daum 어플 에서 주소 호출

= Naver 어플 에서 주소호출



테스트 결과


1. version="2.0"

2. version="2.0"

3. version="2.1"

4. Mobile = Crhome 어플 [ version= "2.1" ]

= Samsung Browser 어플 [ version="2.1" ]

= Daum 어플 [ version="2.1" ]

= Naver 어플 [ version="2.0" ]



모냐 이거... 왜 다 다르냐... 이해할려고 해도 할 수 가 없는 현상...


* 이거는 읽으신분 중에 혹시 아시는분은 답변좀 달아 주셨으면 한다.




저렇게 불확실한거 그냥 서버에 DB만들어서 내가 버전체크해주는게 속 편하다는 생각에 그냥 서버 통신으로 우회..



그래서 필자는 버전체크를 중요치 않은 앱들은 위 방법을 쓰라고 추천해드리지만. 그게 아니면 내부적으로 버전체크하는게 좋다고 본다.





아.. 보기 좋게 만드는거는 나중에 해야겠다 지금은 자다가 빡침에 글올리느라 그냥 끄적끄적...

오늘은 드디어 Firebase 홈페이지를 들어가서 해보자.


월래는 10분 안에 다 끝나는걸 피곤한 관계로 3번에 걸쳐 하게 되니 정말 어렵게 푸는게 아닌지 하는 생각이 든다.



Firebase : https://firebase.google.com/




파이어 베이스에 가입하는거는 패스하자.

누구나 다 할 수 있는거 가볍게 패스.




 1.  첫 화면 체크





2. 파이어 베이스에 프로젝트 만들기



프로젝트 이름을 입력 후 약관 동의를 하면 로딩 화면이 나오면서 완료가 된다.

이러면 파이어베이스에 프로젝트 만들기 끝.




3. 파이어베이스에 IOS 프로젝트 추가 하기




위와 같이 실행 했으면, 프로젝트 이름이 제대로 되어 있는걸 확인할 수 있다.

그렇다면 바로 다음으로 위에 IOS 버튼이 보일 거다. 가볍게 클릭하자.




클릭하면 위와같은 화면이 나오는데

여기서 가장 중요한건 IOS 번들ID 다. 번들아이디가 다르면 모든게 틀어지기 때문에 잘보고 치자.


입력하고나면 앱등록 버튼이 활성화고 다음으로 넘어가자





다음으로 넘어가면 GoogleService-Info.plist 다운로드 하라고 나오는데 똑같이 따라 해주면 된다.


방금 다운로드한 GoogleService-Info.plist 파일을 Xcode 프로젝트의 루트에 이동하여 대상 전체에 추가하세요.

보기 좋게 위치도 이미지와 같은 위치에 넣어주자. 그래야 나중에 찾기도 쉽다.





추가하고 나면 이제 또 다음으로 넘어가자





다음으로 넘어가니 어디서 많이 본것들이 나오는데

우리는 2018/11/13 - [[ 자기개발 ]/개발에 필요한 정보 정리] - [Firebase] IOS APNS 파이어베이스 연동 - (1) 에서 프로젝트에 미리 했기 때문에 패스




엇! 이것도 프로젝트에 미리 해놨기 때문에 패스


이제 다음으로 누르면 [ 앱이 Google 서버와 통신했는지 확인하는 중입니다. 앱을 제거한 후 다시 설치해야 할 수도 있습니다. ]

라고 이렇게 나오지만 가볍게 이 단계 건너뛰기를 눌러주자.




건너 뛰기 하고 설정에 들어가면 아래와 같은 화면이 나오게 된다.



필요한 정보들은 더 추가하면 되고, 빠르게 넘어가자!

위에 [ 클라우드 메시징클릭!



위에 키들은 나중에 서버 개발하면서 쓰는 것이라고만 알고 패스. 하고 아래 빨간칸을 클릭






클릭 후 아래와 같은 팝업창이 나오는데 여기에 잘넣어야 한다.

긴말하지 않곘다 잘넣어야 한다.







절때 쓰면서 귀찮아서 그러는게 아니다. 

저게 끝이다. 마지막으로 연결을 잘 했는지 확인을 해야하는데


확인은...

왼쪽 사이드 매뉴 하단으로 스크롤 해보면 Cloud Messaging 이 있는데.

여기에서 확인해보면 된다.







끄으으으으읕!


정말 이걸로 끝.. 잘 안되면 어쩔 수 없지만.. 한 90% Key값을 잘못넣어서 잘못된거다.

너무우우우 쉽죠?


이만 와이프라 맥주한잔 하러 가야겠다.. ㅎㅎ


참고 주소 :

 - Firebase console : https://console.firebase.google.com

 - IOS Certificates : https://developer.apple.com/account/ios/



아! 피곤...

오늘 하루도 열심히 달리다가

집에서 육아까지.. 열심히 하자!!



2018/11/13 - [[ 자기개발 ]/개발에 필요한 정보 정리] - [Firebase] IOS APNS 파이어베이스 연동 - (1)

에서 해왔던 이어나가보자.



그 다음으로 해야할 것은 developer account cetificate 에 Apns 인증키를 만드는 것이다.

이번글은 Apns 인증키 만들기에 대한 설명이다.



개발자 등록은 하셨을 것이고.

개발자 등록을 하셨으면 인증서 등록을 하셨을 것이고.

인증서 등록을 하셨으면 AppIDs도 만들어 보셨을 거라 생각하고 작성해보자.


- 추후 개발자 등록 & 인증서 등록 & AppIDs 만드는 것도 한번 작성해보자.



머라 할것도 없이 아주 간단하다.


1. 먼저 IOS Certificates 화면으로 이동 후 왼쪽 사이드 부분에 Keys -> All 이 존재한다. 클릭!

   그 뒤 오른쪽 상단에 + 부분이 보이면 클릭!



2. 인증 키 이름을 적기 (신중할 필요는 없음)

 Apple Push Notification service (APNs) 필수로 체크




- 여기서 부터가 중요하다 ! -


3.  아래 이미지에 보이는 빨간색 부분을 잘 참고하기 바란다.

 한번더 설명 해주자면 KeyID 는 FCM 에 등록하기 위해 꼭 필요한 부분이기 때문에 외워두고 따로 적어놓자.

 마지막으로 인증키 다운로드는 1번밖에 안되기 때문에 꼭 백업 하기 바란다




4. 마지막으로 하나더 중요한 부분은 Prefix ID입니다.

Key ID와 같이 Prefix ID도 FCM에 등록하기 위해 꼭 필요한 부분이라는 것,




벌써 끝이다. 우리가 여기서 알아야 할 것은 발급받은 인증키 p8, KeyID, PrefixID 이게 끝이다.




예전에는 인증서가 매번 갱신을 해줘야 하는 번거러움이 있는 반면에 지금은 이거 하나면 다 되니 이 얼마나 편해졌는지 알 수 있다.










파이어 베이스를 통해 푸시 전송 - (1)



참고 주소 :

 - Firebase console : https://console.firebase.google.com

 - IOS Certificates : https://developer.apple.com/account/ios/



파이어베이스의 도큐먼트에 아주 설명이 잘되어 있다.


그러나 오늘 사소한 문제로 인해 한시간을 해매는 현상을 발생하여 이렇게 적어본다.




1. 순서 ( xCode )

- xCode를 이용해 프로젝트 생성

(Bundle ID는 꼭 외워두기)


- 프로젝트에 pod 설정

(2018/05/23 - [[ 자기개발 ]/개발에 필요한 정보 정리] - [ IOS 팁 ] POD 설치 및 사용)


우리는 푸시를 보내기 위한 것이니

Podfile에 

pod 'Firebase/Core'

pod 'Firebase/Messaging'

넣고 pod update를 해준다.


- 프로젝트(xCode) 설정

(순서대로 하면 끝)


- 프로젝트 AppDelegate에 코딩 작성


AppDelegate.h


@import Firebase;

@import UserNotifications;


@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessageDelegate>



AppDelegate.m


1. application:didFinishLaunchingWithOptions:launchOptions


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


}



2. application:didRegisterForRemoteNotificationsWithDeviceToken:


- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

    [FIRMessaging messaging].APNSToken = deviceToken;

}


3. messaging:didReceiveRegistrationToken:


- (void) messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {

/// FCM 에서 사용하는 PUSH 토큰 ///

   //  fcmToken 을 이용해 푸시를 보내야 한다. ///

}





여기까지가 프로젝트의 설정이 이다.


더 하라고해도 할게 없다.


다음에는 Firebase 설정을 넘어 갈것이며, 이것도 그렇게 어렵지 않다.







딱! 주제그대로다.


아직도 서버랑 주고 받는 데이터를 로그로 확인하니?



클라이언트일때, 서버일때도 마찬가지!


서버가 어떤 데이터를 주는지?


데이터를 제대로 주고 있는지?


내가 값을 정확히 넘겨 주는지?





확인하기 위해 -> 코드로 데이터 만들어서 -> 빌드해서 -> 통신해서 -> 로그 나오는 걸로 확인한다면...


당신은 왕초보!



나는 그냥 초보!





그래서, 추천해주고 싶은 프로그램은 [ Postman ] 이다.








Postman은 Chrome의 확장프로그램으로 크롬을 다운받고 사용해야 한다.



1. 크롬 설치


2. 오른쪽 상단에 3개의 점이 있다. 클릭!


3. 도구 더보기 -> 확장 프로그램 -> 더 많은 확장프로그램 다운로드


https://chrome.google.com/webstore/category/extensions?hl=ko



4. 스토어검색 -> postman



이렇게 설치하고 쓰면 된다.





쓰는 방법은 간단하다.



개발 좀 해보신분들은 한눈에 알것이고,


모르시는 분들은 쓰면서 알아가면 좋을거다.



난 추천만 하지 알려주기에 타자치기가 너무 귀찮다 ㅋㅋ





간단하게 팁을 알려주자면



0. 히스토리가 존재해 내가 언제 어떻게 보냈는지 로그가 남는다.


0. 내가 보낸 주소&정보들을 저장해놓고 다음에 불러와서 다시 쓸 수 있다.


0. 내가 저장해 놓은 정보들을 Export할 수 있어 서버나 클라이언트에게 한번에 넘겨주기 쉬워 시간 절약이 된다.


0. 여러 형식을 지원하기 때문에 무엇때문에 잘못 되었는지 한눈에 알기 쉽다.





머 이정도? 만 알면 끝.











+ Recent posts