Giter VIP home page Giter VIP logo

Comments (3)

rslota avatar rslota commented on May 26, 2024

Hi @theanhoo ,

Apparantly FCMv1 does not tolerate values that are not a string within data payload. I'm adding bugfix task to esl/sparrow backlog.
Until this is resolved please pass all values as strings to MongoosePush API - here the problem is specifically with: "message-count": 1.

from mongoosepush.

theanhoo avatar theanhoo commented on May 26, 2024

Hi, @rslota,

I've removed binary_to_integer from the following function in MongooseIM:

%% Create notification for API v2
make_notification(v2, Notification, Options = #{<<"silent">> := <<"true">>}) ->
    %% MessageCount = binary_to_integer(maps:get(<<"message-count">>, Notification)),
    MessageCount = maps:get(<<"message-count">>, Notification),
    {ok, #{
        service => maps:get(<<"service">>, Options),
        mode => maps:get(<<"mode">>, Options, <<"prod">>),
        topic => maps:get(<<"topic">>, Options, null),
        priority => "high",
        data => Notification#{<<"message-count">> => MessageCount}
    }};
make_notification(v2, Notification, Options) ->
    {ok, #{
        service => maps:get(<<"service">>, Options),
        mode => maps:get(<<"mode">>, Options, <<"prod">>),
        alert => #{
            body => maps:get(<<"last-message-body">>, Notification),
            title => maps:get(<<"last-message-sender">>, Notification),
            tag => maps:get(<<"last-message-sender">>, Notification),
            badge => binary_to_integer(maps:get(<<"message-count">>, Notification)),
            click_action => maps:get(<<"click_action">>, Options, null)
        },
        topic => maps:get(<<"topic">>, Options, null)
    }}.

This is the request:

{
	"message": {
		"android": {
			"data": {
				"last-message-body": "6",
				"last-message-sender": "[email protected]",
				"message-count": "1"
			},
			"notification": {},
			"priority": "HIGH"
		},
		"data": {},
		"notification": {},
		"token": "XXX"
	}
}

And this is the response:

2019-11-28T16:55:39.082 [debug] pid=<0.1820.0> action=send, item=request_response, to={#PID<0.1971.0>, #Reference<0.733623136.701235201.235185>}, headers=[{":status", "400"}, {"vary", "X-Origin"}, {"vary", "Referer"}, {"vary", "Origin,Accept-Encoding"}, {"content-type", "application/json; charset=UTF-8"}, {"date", "Thu, 28 Nov 2019 08:55:39 GMT"}, {"server", "ESF"}, {"cache-control", "private"}, {"x-xss-protection", "0"}, {"x-frame-options", "SAMEORIGIN"}, {"x-content-type-options", "nosniff"}, {"alt-svc", "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q050=\":443\"; ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000"}, {"accept-ranges", "none"}], body={
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT"
  }
}

Please advise.

Many thanks in advance.

from mongoosepush.

theanhoo avatar theanhoo commented on May 26, 2024

I have switched back to MongoosePush 1.0.6. That seems to work fine.

from mongoosepush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.