Android
2018.09.22 / 11:22

¾ÛÀÌ background »óÅÂÀ϶§, FCM Notification event handler ¸¦ ¼ö½ÅÇÏÁö ¸øÇÏ´Â °æ¿ì

xClick
Ãßõ ¼ö 198

¸» ±×´ë·Î´Ù. À̰Ŷ§¹®¿¡ ¹«·Á ÀÌƲÀ» »ðÁúÇߴµ¥, ±× °á°ú¸¦ Àû´Â´Ù.

ÀÏ´Ü, FCM Àº GCM ´ÙÀ½ ³ª¿Â android notification ÀÌ´Ù. ( notification À» Çѱ۷Π¹¹¶ó ÇØ¾ß Çϳª? "¾Ë¸²" Çعö¸®¸é Alarm À̶û Çò°¥¸°´Ü ¸»¾ß. )

ÀÌ°Å ¾²´Â ¹æ¹ýÀÌ¾ß ÀÎÅÍ³Ý º¸¸é ¸¹ÀÌ ÀÖ´Ù. ´ëÇ¥ÀûÀÎ °Ç

http://blog.naver.com/PostView.nhn?blogId=cosmosjs&logNo=220739141098&parentCategoryNo=56&categoryNo=&viewDate=&isShowPopularPosts=true&from=search

http://www.inflater.co.kr/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-fcm%EB%9D%BC%EC%9D%B4%EB%B8%8C%EB%9F%AC%EB%A6%AC/


¿©±âÀú±â ¸¹°í, ³»°¡ ÇÊ¿äÇß´ø °Ç

1. background service ·Î µ¹¾Æ°¡´Â ¾ÛÀÌ

2. ¼­¹öÀÇ FCM notification À» ¹Þ¾Æ¼­

3. µî·ÏµÈ event handler ¸¦ ½ÇÇàÇؼ­ ÀÛ¾÷ÇÏ´Â °Í. 


º° °Å ¾ø´Ù. ½±°Ô¸»ÇØ "ÆùÀ¸·Î ¿À¶ôÇÏ´ø »ç¿ëÀÚ°¡, Ä«Åå ¾Ë¸² ¿À¸é Ä«Åå ÇÁ·Î±×·¥ ½ÇÇàµÇ´Â °Í'

Â÷ÀÌÁ¡Àº, Ä«Åå ¾Ë¶÷ÀÇ °æ¿ì »õ·Î¿î ±ÛÀÌ ¿À¸é »ç¿ëÀÚ°¡ ¸Þ½ÃÁö¸¦ "Ŭ¸¯" Çؼ­ À̵¿ÇÏÁö¸¸, ³ª´Â ÀÚµ¿À¸·Î(=Ŭ¸¯¾øÀÌ) ¾ÛÀÌ ½ÇÇàµÇ´Â °Í. 


±×·±µ¥, ¾Æ¹«¸® ÇØ ºÁµµ ÀÏ´Ü background service ·Î µé¾î°£ ¾ÛÀº FCM noti ¸¦ ¸ø ¹Þ´õ¶ó. foreground ÀÏ ¶§¸¸ event handler °¡ ½ÇÇàµÇ´õ¶ó°í. 

±Ùµ¥, ¾Æ¹«¸® ÀÎÅͳÝÀ» µÚÁ®ºÁµµ background service ÀÏ ¶§ ¾È µÈ´Ù´Â À̾߱Ⱑ ¾ø´õ¶ó°í. 
FCM¿¡ ´ëÇØ ±Û ½á ³õÀº »ç¶÷µé º¸¸é, º° ¾î·Á¿ò ¾øÀÌ ±×³É µÇ´Â ´À³¦ÀûÀÎ ´À³¦.

»ý°¢ÇÒ ¼ö ÀÖ´Â º° Á¶ÇÕÀ» ´Ù Çغ¸´Ù°¡ °á±¹ µÇ¼­, ±× »ðÁú°úÁ¤À» Àû´Â´Ù. ´Ù¸¥»ç¶÷Àº ³ª¿Í °°Àº »ðÁúÀ» ÇÏÁö ¾Ê±æ ¹Ù¶õ´Ù. 


1. background »óÅÂÀÏ °æ¿ì, google FireBase »çÀÌÆ®¿¡¼­ noti ³¯·Áµµ ¼ö½Å¾ÈµÈ´Ù.

Foreground »óÅÂÀ϶§´Â µÈ´Ù. Background »óÅÂÀÏ ¶§¸¸ ¾ÈµÇ´Â °ÅÀÓ. 

2. background »óÅ ¼ö½Å Å×½ºÆ® ÇÏ·Á¸é, À¥¼­¹ö¸¦ ¸¸µé¾î¼­ Å×½ºÆ® ÇÏ´ø°¡, postman À» ¼³Ä¡Çؼ­ Å×½ºÆ® ÇØ ºÁ¶ó.

postman Àº À¥¾ÛÀε¥, REST API Å×½ºÆ®¸¦ À¥¼­¹ö ¾øÀÌ ÇÒ ¼ö ÀÖ°Ô ÇØÁØ´Ù. 

ÆíÇÑ °Ç °¡Á®´Ù ¾²ÀÚ. °øÂ¥ÀÓ.

http://ourcstory.tistory.com/6

https://velopert.com/362

background »óÅÂÀÇ ¾ÛÀº https://fcm.googleapis.com/fcm/send ¸¦ °æÀ¯Çؼ­ noti ¸¦ Àü´ÞÇØ¾ß À̺¥Æ® 󸮰¡ °¡´ÉÇÏ´Ù. 

3. FCM noti body ¿¡ notification ¾²Áö¸¶¶ó. data ½á¶ó.

ÀÌ°Ô ÇÙ½ÉÀÌ´Ù. 

Á¤È®ÇÏ°Ô ±â¾ïÀÌ ¾È³ª´Âµ¥, ¾î·´ø FCM ÀÌ ´Ü¸»¿¡ ¸Þ½ÃÁö¸¦ º¸³»´Â ¹æ¹ýÀº µÎ °¡Áö°¡ ÀÖ´Ù. 

¸Þ½ÃÁöÀÇ Å° °ªÀ¸·Î "notification" À» ¾²´Â ¹æ¹ý°ú "data" ¸¦ ¾²´Â ¹æ¹ý

ÄÚµå´Â ´ë·« ¾Æ·¡¿Í °°´Ù. 

{
"notification" {
"title" : "title2",
"body" : "bodytest2"
},
"to" : "..."
"data" : {
"message" : "°¡³ª´Ù¶ó¸¶"
}
}
}

key °¡ "notification" ÀÎ °Í°ú "data" ÀÎ °Ô Â÷ÀÌ°¡ ÀÖ´Ù. ¹¹°¡ Â÷ÀÌ¿´´ÂÁö´Â Àؾî¹ö·ÈÁö¸¸, ÇÏ¿©Æ° Å×½ºÆ®Çϸ頴ٸ§. 

°á·ÐºÎÅÍ ¸»Çϸé, key ¸¦ "notification" À» ¾²¸é foreground À϶§´Â ¼ö½ÅµÇÁö¸¸, background À϶§´Â ¼ö½Å ¾ÈµÈ´Ù.
key ¸¦ "data" ·Î ½á¾ß background À϶§µµ ¼ö½ÅµÈ´Ù. 


[ ÁøÂ¥ ÀÌƲ° ÀÌ·± ±âºÐÀ̾ú´Ù. ]



Ãâó: http://ckbcorp.tistory.com/1115 [...]