简体   繁体   English

Cordova Firebase插件-在iOS的通知栏中不显示通知

[英]Cordova Firebase Plugin - Not showing notifications in notification bar on iOS

I'm using this plugin with cordova: cordova-plugin-firebase 0.1.18 "Google Firebase Plugin" its working fine on android,also on ios i got token using method 我将此插件与cordova配合使用:cordova-plugin-firebase 0.1.18“ Google Firebase插件”在android上也能正常工作,在ios上我也使用了方法

window.FirebasePlugin.getToken

but notification not coming in notification bar weather its in foreground or background call back of notification never come in using method 但是通知没有进入通知栏,它的前台或后台没有使用方法来回叫通知

window.FirebasePlugin.onNotificationOpen

on server side i am posting like this, 在服务器端,我这样发布

def sendNotfMessage(def registrationIds,def body,def title){
            def data  = [:]
            data['body']=body
            data['title']=title
            data['icon']="myicon"
            data['sound']="mySound"
            def postJson = [:]
            postJson['priority'] = "high"
            postJson['notification'] = data
            postJson['registration_ids']=registrationIds
            return sendFcmNotf(postJson)
        }


def sendFcmNotf(def postJson){

    HttpTransport transport = new NetHttpTransport()
    HttpRequest request = transport.createRequestFactory().buildPostRequest(new GenericUrl("https://fcm.googleapis.com/fcm/send"), new JsonHttpContent(new JacksonFactory(), postJson));
    HttpHeaders reqHeaders = new HttpHeaders()
    reqHeaders.setAuthorization("key=${grailsApplication.config.android.fcm.api.key}")
    reqHeaders.setAccept("application/json")
    reqHeaders.setContentType("application/json")

    request.setHeaders(reqHeaders)

    request.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff.Builder()
            .setInitialIntervalMillis(500)
            .setMaxElapsedTimeMillis(900000)
            .setMaxIntervalMillis(6000)
            .setMultiplier(1.5)
            .setRandomizationFactor(0.5)
            .build()
            ))

    try {


        HttpResponse response = request.execute();

        InputStream is = response.getContent()
        BufferedReader br = new BufferedReader(new InputStreamReader(is))

        StringBuilder sb = new StringBuilder();

        String line = null;
        try {
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        ObjectMapper mapper = new ObjectMapper()
        Map<String, Object> responseMap = mapper.readValue(sb.toString(), new TypeReference<Map<String, Object>>(){})

        // Process response JSON per https://firebase.google.com/docs/cloud-messaging/server#response
        if(responseMap && (responseMap['failure'] != 0 || responseMap['canonical_ids'] != 0)){
            if(responseMap['message_id'] && responseMap['registration_id']){

                log.info "New push token, setting to ${responseMap['registration_id']}"

                // TODO Notify backend that token has changed, i.e. update

            }

        }else{

            def results = responseMap['results']

            if(results){

                results.each{

                    if(it['error']){

                        if(it['error'] == "NotRegistered"){

                            log.info 'NotRegistered, updating AppToken to null'

                            // TODO Notify backend this token is no longer valid, i.e. delete

                        }
                    }

                }

            }

        }


        return responseMap

    }catch(HttpResponseException e){

        log.error "Error: ${e.toString()}"

        return (['SC' : e.getStatusCode(), 'M' : e.getStatusMessage() ])

    }
}
}

i got it ,actually i miss to upload APNs certificate at 我知道了,实际上我想念在上载APNs证书

console.firebase.google.com 

you can refer the link for more details. 您可以参考该链接以获取更多详细信息。 https://firebase.google.com/docs/cloud-messaging/ios/client ? https://firebase.google.com/docs/cloud-messaging/ios/client

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 cordova,Firebase,FCM插件 - 未在iOS上的通知栏中显示通知 - cordova, Firebase, FCM Plugin - Not showing notifications in notification bar on iOS 带有phonegap-plugin-push和Firebase的Cordova iOS通知。 没工作 - Cordova iOS notifications with phonegap-plugin-push and Firebase. No work 使用Phonegap插件在IOS Cordova上收到Firebase FCM通知 - Firebase FCM notification to received on IOS cordova using the Phonegap Plugin firebase通知cordova ios集成 - firebase notification cordova ios integration 适用于iOS 10的cordova firebase插件 - cordova firebase plugin for ios 10 + 用于 ios 的cordova-plugin-firebase - cordova-plugin-firebase for ios 如果应用程序处于iOS应用程序的前台,则Cordova插件Firebase未收到推送通知 - Cordova plugin Firebase did not receives push notifications if app in foreground for iOS application 当应用程序使用Cordova Firebase插件在iOS上的前台运行时,通知会同时发送到设备和应用程序 - Notifications delivered to both device and app when app is running in the foreground on iOS using Cordova Firebase Plugin 将Firebase通知与本地通知一起使用iOS - Use firebase notification with local notifications iOS iOS的Cordova-Plugin-Firebase:设备收到推送通知,但未显示在设备上 - Cordova-Plugin-Firebase, iOS: device receives push notification but does not appear on device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM