So, after hours of work I eventually found out where it stucks. Since I am using mysql as database backend I was able to break down the issue. There is a called table ofPushNotiSevice:
In this table are beeing stored all push notification services of each user what have accepted push trough their app on their phone.
Unfortunaltely sknikket sends no data for the field “options” and the plugin “push notification” sets it to NULL.
When this user is offline then and someoneelse sends now a message happens this:
Push notification plugin intercepts the message and runs its code until it finds a record in mentioned table above. If it does not find a message, no push notifacation will be sent. In case there is a record it saves all fields in variables. Since the field is NULL push notifiications considers this record as not usable and spits out ecactly the error I had been posting above. “User has 0 push notification services configured.”
I have been trying to modify the field directly in the database uncseccessfully by leaving any character or even leaving it empty . Then I copied and pasted the value what the app “Chatsecure” has forseen for this field and BINGO. Push notifications are being sent. I don’t have any clue why push notication app considers this field since it is optional by XEP-357.
See picture:
SInce every opening of the app or re-registering of the user manualy through the app sets the field again to NULL, I easely have set a trigger directly in the datebase what fills the field.
For reaching this I needed a kind of PINGPONG since it is not doable writing through a trigger in the same table where something needs to be modified.
- Create another table where data will be stored taken from table ofOffline
CREATE TABLE IF NOT EXISTS push_notification
(
id
int(11) NOT NULL,
message_id
int(11) NOT NULL,
from_user_id
text NOT NULL,
to_user_id
text NOT NULL,
message
text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
- Create a trigger in table ofOffline what sends date to new table after they have just arrived
–
– Triggers ofOffline
DELIMITER //
CREATE TRIGGER PushNotification
AFTER INSERT ON ofOffline
FOR EACH ROW BEGIN
DECLARE strMessageText VARCHAR(500) DEFAULT '';
DECLARE strSenderId VARCHAR(500) DEFAULT '';
DECLARE strReceiverId VARCHAR(500) DEFAULT '';
DECLARE intMessageId INT DEFAULT 1;
SET strMessageText = ExtractValue(NEW.stanza, 'message/body[1]');
SET strSenderId = ExtractValue(NEW.stanza, 'message/@from[1]');
SET strReceiverId = ExtractValue(NEW.stanza, 'message/@to[1]');
SET intMessageId = NEW.messageID;
INSERT INTO push_notification (message_id,from_user_id,to_user_id,message) VALUES (intMessageId,strSenderId,strReceiverId,strMessageText);
END
//
DELIMITER ;
- Create a trigger in table push_notification what sets the desired field
CREATE TRIGGER `IfNotiOptionsEmpty` BEFORE INSERT ON `push_notification`
FOR EACH ROW UPDATE ofPushNotiService SET options = '<x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE"><value>http://jabber.org/protocol/pubsub#publish-options</value></field><field var="token"><value>iftheappisstupid</value></field><field var="endpoint"><value>https://myDomain.net</value></field></x>' where options is NULL
It does not matter at al what is this this field. Importent is just it has to be the format like in the last trigger.
Hope I could help.
Regards,
Andre