How do I establish a connection to an existing components code from a new component

bryce alvord Posted in Component Development 5 years ago

Im writing a component that will use some core functionality of one of the stock OSSN components. Im wondering if there is something built into the OSSN framework that allows me to import a component into mine essentially so that I can call its functions and have the class accessible to me. I hate copying code that performs simple tasks and creating a new code fork vs. tapping into the core functionality in its pure form. I know I can include those files too, just wondering if there is a better way that is less sensitive for me to do this.

So lets say I am wanting to create a notification for example. Well a lot goes into thos notifications from what I can tell in the OSSN Notifications component so my thought process is why recreate the wheel when I can hopefully "import" OSSNNotifications and call a OSSNNotifications.CreateNotification() method (pseudo code obviously).

Thanks

This topic has been closed!

[Topic is Close]

Replies
Indonesian Arsalan Shah Replied 5 years ago

@Bansh33, please contact us at contact form, i will connect with you there. We can discuss about the mprovement.

us Rishi B Replied 5 years ago

Arsalan,

I understand that the mobile app is provided by Softlab24 which is a separate entity, and I do appreciate you personally taking the time to respond to my bug report about the mobile app last week. That being said, it's extremely frustrating for developers like myself who are perfectly capable of writing an app our selves to have to see this kind of thing, and not be able to do anything about it. While I can reinvent the wheel, I don't particularly want to. I will just say that I have seriously considered writing my own version of a native OSSN mobile app simply because the current (paid) offerings leave a lot to be desired. That said, I do understand that mobile apps are not the primary focus of Softlab24 as a company, and I'm certainly not faulting you personally for it.

Bryce, unfortunately I haven't even tried the iOS version of the app, only the Android version, which works (for me) in the way I described below. It seems the mods here do not want the discussion to continue in the direction of mobile solutions, so I'll just say that I'm pretty sure your notification looks just fine.

Indonesian Arsalan Shah Replied 5 years ago

It seems my message below was not seen by you anyone?, further about the apps i suggest you to contact softlab24 using correct channel. Further the notifications for IOS currently being disabled by us, so you will only receive it on android. There isn't any developers guide for app provided by softlab24 as its not opensource.

I request you to stick with original topic (OssnNotification on site) not on mobile app push notifications.

us Bryce alvord Replied 5 years ago

Based on very limited testing it seems like when you post through the app it does create the messages but did not trigger push notifications for people that have the app and are not currently logged into it or the website. The testing was performed using my wifes iphone where she primarily uses the app. I will do more thorough testing tonight because last night another family member created a post using the site and I got a push notification from the app on my phone (android). I will keep you posted, pun intended

us Rishi B Replied 5 years ago

your code looks fine to me btw. I really don't think it could be a problem with the code if the message is correctly received via the web interface. That sounds like either 1) an odd, specific problem with the mobile app, or 2) the issue I described in my previous post about new messages not coming through to the mobile app as a push notification after they've been marked as viewed. Another thing I've noticed is that you may see only the most recent message from the sender displayed in your mobile phone's notification list.

us Rishi B Replied 5 years ago

so, if users are receiving the message correctly, that means the messages must be getting correctly added to the database. Have you checked the ossn_messages table to verify this? I think what may be happening is that the user is viewing the message via the web interface, and because it's already marked as viewed, it's not coming through as a push notification. Aside from that, have you checked that you're using the latest version of the mobile app? For me, all messages that are unviewed definitely come thru to the mobile app. I have some other stuff added to my messaging setup (for example, I have an SQL trigger to record the time that a message is viewed for "read receipts") and all of it seems to come thru fine to the mobile app.

us Bryce alvord Replied 5 years ago

So its funny you suggested that Bansh33, I did create a messages version of the component as well trying to get the push notifications to happen on the mobile devices and unfortunately what I did to send a message does not trigger a push notification for some reason, Im not sure why. This is my com code which is really all of the code for it. Maybe you can see something I did wrong because it does send the message to all users that a post was created however that message doesnt trigger the push notifications.

<?php
define('__POST_MESSAGES__', ossn_route()->com . 'PostMessages/');

function post_messages() {
    ossn_register_callback("wall", "post:created", "postMessagesHandler");
}

function postMessagesHandler($callback, $type, $params) {
    $messages = new OssnMessages;
    $user = new OssnUser;
    $users = $user->getSiteUsers(['page_limit' => false]);
    $message = 'I have created a new post';

    foreach ($users as $key => $value) {
        // send the message to all users except the posting user
        // error_log("NEW NOTI: " . ossn_dump($params));
        if ($value->guid != $params['poster_guid']) {
            $messages->send($params['poster_guid'], $value->guid, $message);
        }
    }
}

ossn_register_callback('ossn', 'init', 'post_messages');
us Rishi B Replied 5 years ago

Why not dispatch both a notification (as you've been doing), as well as send a message? That way, mobile users will get a push notification, and Web users will see the notification where they expect. Not the prettiest solution due to the obvious redundancy, but there's only one other workaround I can think of, which would require significantly more work. This would be to create a "special" kind of message - one that does not show up in the message lists on the website (edit the OssnMesages and OssnChat components). There's no need to get deep into the specifics unless you actually wanna go that route, but you would need make sure that message doesn't show up on the messages list, nor renders anything on the dropdown menu that usually shows new messages. Because the mobile app does not load content in the same way, I'm pretty sure it would still be delivered to the mobile app as a push notification. One downside is that it would probably still show up in the messages list on the mobile app - which nothing can be done about since the app is closed source. Btw, I'm NOT positive this would work, just something that popped into my head, so I figured I'd throw it out there. I still think dispatching the normal notification + a message is your best bet.

Indonesian Arsalan Shah Replied 5 years ago

Hi Bryce, If you mean by softlab24 app then notifications are not supported for 3rd party components. I mean all is managed by softlab24 itself.

us Bryce alvord Replied 5 years ago

Yes I am just doing this on a small site of less than 10 users that won't expand much if at all. So are there thoughts of how to keep the notifications setup I have and trigger the push notification code for the app? I can take the same concepts now and switch to messages if I must, just not sure how the app interfaces. Thanks!