...
The minimal requirements for that functions to workswork, resource listing , and detail API need to response respond Extra permission and Feed Param schema.
...
The following image is an example response of PostResource
Integrate Activity Feeds
Activity feed on Native Mobile App is control controlled by Feed API
- API: /feed
- Method: GET
Requirement:
- Activity Feed feature of the Item works on the website
- Feed API response "embed_object" with minimal following fields
- resource_name
- module_name
- id
- title
Control Main Activity Feed Embed response
By default, if resource name and feed type id storage ID stored in the database is the same. We , we just need to implement ActivityFeedInterface interface of related API Service to control the output.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<?php class PostApi extends AbstractResourceApi implements ActivityFeedInterface, MobileAppSettingInterface { /*...*/ /** * Get for display on activity feed * @param array $feed * @param array $item detail data from database * @return array */ public function getFeedDisplay($feed, $item) { $categoryCond = [ 'post_id' => [] ]; /** @var PostCategoryApi $categoryReducer */ $categoryReducer = $this->getCategoryApi(); $categoryCond['post_id'][] = $item['post_id']; $categoryReducer->reduceFetchAll($categoryCond); $item['categories'] = $categoryReducer->reduceQuery([ 'post_id' => $item['post_id'] ]); return $this->processRow($item) ->toArray(['resource_name', 'module_name','id','title','categories','description','image']); } } |
Control other activity feed type
If the feed type id ID cannot map with any resource API service. We can create a custom feed type to control the output.
...
Modify hook "mobile_api_routing_registration.php" and add the following code to map feed type id store ID stored in database with new custom feed handler
Code Block | ||||
---|---|---|---|---|
| ||||
/*...*/ Phpfox::getService('mobile.helper.feedPresentation') ->addEmbedTypes('post_special_feed_type', \Apps\Posts\Api\Feed\CustomFeedEmbed::class); /** * If API resource name is different with Phpfox app's alias. * we need add map resource_name (in this case is "post") with app_alias as following example */ $this->specialModules['post'] = 'app_alias_name'; |
Integrate Like, Comment features
If like, comment features are working on the website and you have implement implemented resource response same as above, the features will workswork.
If your resource name and comment , / like type in PHPFOX system or are different, you can override in resourceResource
Code Block | ||||
---|---|---|---|---|
| ||||
<?php /*...*/ class PostResource extends ResourceBase { public function getCommentTypeId() { return "post"; } public function getLikeTypeId() { return "post"; } } |