ios - Firebase notification not showing banner in background and not called didReceiveRemoteNotification -
- added , downloaded certificates
- created(development:ios app development,distribution: app store, status both active) , double-clicked profiles
- Сreated 2 .p12 file. press on key , certificate, not care.
- uploaded 2 .p12 firebase
- activated push notifications , background modes in xcode.
firebaseappdelegateproxyenabled = no
- 2016-11-08 14:54:05.115350 informator[433:134942] warning: firebase analytics app delegate proxy disabled. log deep link campaigns manually, call methods in firanalytics+appdelegate.h.
- 2016-11-08 14:54:05.431: firmessaging library version 1.2.0
- 2016-11-08 14:54:05.553874 informator[433:135005] [firebase/core][i-cor000001] configuring default app.
- 2016-11-08 14:54:05.555 informator[433] [firebase/core][i-cor000001] configuring default app.
- 2016-11-08 14:54:05.564098 informator[433:135004] firebase analytics v.3404000 started
- 2016-11-08 14:54:05.564 informator[433:] firebase analytics v.3404000 started
- 2016-11-08 14:54:05.577170 informator[433:135004] enable debug logging set following application argument: -firanalyticsdebugenabled (see http)
- 2016-11-08 14:54:05.579 informator[433:] enable debug logging set following application argument: -firanalyticsdebugenabled (see http)
- 2016-11-08 14:54:05.580: failed fetch apns token error domain=com.firebase.iid code=1001 "(null)" instanceid token: //mytoken
- 2016-11-08 14:54:06.008: apns environment in profile: development
- 2016-11-08 14:54:06.485282 informator[433:135007] [firebase/core][i-cor000019] clearcut post completed.
- 2016-11-08 14:54:06.486 informator[433] [firebase/core][i-cor000019] clearcut post completed.
- 2016-11-08 14:54:06.532779 informator[433:135007] adsupport framework not linked. features not function properly. learn more @
- 2016-11-08 14:54:06.533 informator[433:] adsupport framework not linked. features not function properly. learn more @
- 2016-11-08 14:54:06.555163 informator[433:135004] firebase analytics enabled
- 2016-11-08 14:54:06.555 informator[433:] firebase analytics enabled connected fcm.
%@ [anyhashable("from"): myid, anyhashable("notification"): { body = mynotification; e = 1; }, anyhashable("collapse_key"): mypacket]
import uikit import usernotifications import firebase import firebaseinstanceid import firebasemessaging import bryxbanner @available(ios 8.0, *) @uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate { var window: uiwindow? func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool { userdefaults.standard.setvalue(user.registeredonthisdevice, forkey: "registered") // [start register_for_notifications] if #available(ios 10.0, *) { let authoptions : unauthorizationoptions = [.alert, .badge, .sound] unusernotificationcenter.current().requestauthorization( options: authoptions, completionhandler: {_,_ in }) // ios 10 display notification (sent via apns) unusernotificationcenter.current().delegate = self // ios 10 data message (sent via fcm) firmessaging.messaging().remotemessagedelegate = self } else { let settings: uiusernotificationsettings = uiusernotificationsettings(types: [.alert, .badge, .sound], categories: nil) application.registerusernotificationsettings(settings) } application.registerforremotenotifications() // [end register_for_notifications] firapp.configure() // add observer instanceid token refresh callback. notificationcenter.default.addobserver(self, selector: #selector(self.tokenrefreshnotification), name: .firinstanceidtokenrefresh, object: nil) //... return true } func application(_ application: uiapplication, didregisterforremotenotificationswithdevicetoken devicetoken: data) { firinstanceid.instanceid().setapnstoken(devicetoken, type: .sandbox) }
in .prod spamming error: unable connect fcm. optional(error domain=com.google.fcm code=2001 "(null)")
// [start receive_message] func application(_ application: uiapplication, didreceiveremotenotification userinfo: [anyhashable: any], fetchcompletionhandler completionhandler: @escaping (uibackgroundfetchresult) -> void) { // print full message. print("%@ 1", userinfo) } // [end receive_message] // [start refresh_token] func tokenrefreshnotification(_ notification: notification) { print("tokenrefreshnotification") if let refreshedtoken = firinstanceid.instanceid().token() { print("instanceid token: \(refreshedtoken)") } // connect fcm since connection may have failed when attempted before having token. connecttofcm() } // [end refresh_token] // [start connect_to_fcm] func connecttofcm() { firmessaging.messaging().connect { (error) in if (error != nil) { print("unable connect fcm. \(error)") } else { print("connected fcm.") } } } // [end connect_to_fcm] func applicationdidbecomeactive(_ application: uiapplication) { connecttofcm() socketiomanager.sharedinstance.establishconnection() } // [start disconnect_from_fcm] func applicationdidenterbackground(_ application: uiapplication) { socketiomanager.sharedinstance.closeconnection() firmessaging.messaging().disconnect() print("disconnected fcm.") //userdefaults.standard.setvalue(user.registeredonthisdevice, forkey: "registered") } // [end disconnect_from_fcm] } // [start ios_10_message_handling] @available(ios 10, *) extension appdelegate : unusernotificationcenterdelegate { // receive displayed notifications ios 10 devices. func usernotificationcenter(_ center: unusernotificationcenter, willpresent notification: unnotification, withcompletionhandler completionhandler: @escaping (unnotificationpresentationoptions) -> void) { let userinfo = notification.request.content.userinfo // print message id. print("message id: \(userinfo["gcm.message_id"]!)") // print full message. print("%@2", userinfo) } } extension appdelegate : firmessagingdelegate { // receive data message on ios 10 devices. func applicationreceivedremotemessage(_ remotemessage: firmessagingremotemessage) { print("%@", remotemessage.appdata) } } // [end ios_10_message_handling]
sorry, cant upload more 2 screenshots.
edit: server send
var payloadok = { to: answ.token, data: { 'category': quest[0].category, 'title': 'Новый ответ', 'body':'На ваш вопрос ответили' }, notification: { 'title': 'Новый ответ', 'body': 'На ваш вопрос ответили' }, aps: { alert: { 'body': "Новый ответ", 'title': 'На ваш вопрос ответили', 'category': quest[0].category }, badge: 3, 'content-available': 1 }, priority: 'high', content_available: true }
my response:
%@ [anyhashable("category"): Услуги и аренда, anyhashable("body"): На ваш вопрос ответили, anyhashable("notification"): { body = "\u041d\u0430 \u0432\u0430\u0448 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0438"; e = 1; title = "\u041d\u043e\u0432\u044b\u0439 \u043e\u0442\u0432\u0435\u0442"; }, anyhashable("collapse_key"): kg.artlabteam.informator, anyhashable("from"): 237178515128, anyhashable("title"): Новый ответ]
Comments
Post a Comment