Comments (8)
I figured this out, for anyone trying to do this, @promaticsArun
- Declare a variable e:g var arrStory : IGStories?
- After getting response from your stories API
let dataFromJSON = json["data"]
let str = dataFromJSON.description
let jsonData = str.data(using: .utf8)!do { let jsonDecoder = JSONDecoder() let stories = try jsonDecoder.decode(IGStories.self, from: jsonData) self.arrStory = stories } catch { print("Unexpected error: \(error).") }
You need to ask your backend to create the same model as the one in stories.json file. If everything is okay you now have stories object and next you can use it to return numberOfItems, cellForItem and in didSelect.
Once again I am really thankful of this awesome library for saving so much time. I just had to make some little tweaks according to my preferences and it all works so smooth!
from instagram_stories.
Hi @codobuxsocial
Thanks for using it.
Actually the loadAPIResponse here you have to make the call for your own backend.
Refer the stories.json file, then you will get to know some basic idea. See for us, we dont have any backend. Simply we went with JSON, and load the JSON and handle it.
Let us know if you need anything else. or further information.
from instagram_stories.
Hi @promaticsArun,
Have you worked with models on your projects? Is that our stories.json and the response what you are getting is same in structure?. Please first refer our stories.json and our models. Compare the key values. If it has different keys on your json, then modify the keys based on that.
IGStories => It is the root model.
IGStory => Which represents single story and it has the single story data. So, IGStories model having array of IGStory.
IGSnap => Story might have many snaps like images or videos. That single image record or video record called Snap. So, IGSnap model contains that data.
IGUser => This model contains the user related data, who posted that story.
The above one is hierarchy order. First try to understand this logic. Once you got my point post your reply. Will discuss further. Will go step by step. Don't jump into implementation directly. First try to understand the code. If you understood, you can shape the code however you want.
Regards,
Boominadha Prakash
from instagram_stories.
I am trying to implement in ios swift but i stuck in model i am unable to understand how to implement this thorugh my Model and also give me suggestion which model class or viewModel class are modified accodring to me with help of API.
from instagram_stories.
Hi @promaticsArun
Thanks for using it.
First, go through our stories.json you will automatically come to know. And when you are getting a response from the server. please match with our stories.json -> BASED ON THIS JSON RESPONSE ONLY - we have implemented this library.
If you want to explore the Models => Source Folder -> Models -> Here you can find models
Let me know if you need anything else
from instagram_stories.
{
"code": 200,
"stories": {
"count": 29,
"rows": [
{
"id": 1,
"user_id": "1",
"story_media": [
{
"id": 1,
"story_id": "1",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/1581750774064check.png",
"media_type": "image"
},
{
"id": 2,
"story_id": "1",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/1581750774103apple-macbook-air-2017-05.jpg",
"media_type": "image"
},
{
"id": 13,
"story_id": "1",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15821896478711582189639554.png",
"media_type": "image"
},
{
"id": 14,
"story_id": "1",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15821896598271582189652004.png",
"media_type": "image"
},
{
"id": 15,
"story_id": "1",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15821898018851582189793362.png",
"media_type": "image"
},
{
"id": 16,
"story_id": "1",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15821898171341582189809899.png",
"media_type": "image"
}
],
"user_story_data": null
},
{
"id": 8,
"user_id": "29",
"story_media": [
{
"id": 10,
"story_id": "8",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15821138806641582113855755.png",
"media_type": "image"
}
],
"user_story_data": {
"name": "misha"
}
},
{
"id": 10,
"user_id": "7",
"story_media": [
{
"id": 12,
"story_id": "10",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/15821195530981582119530403.png",
"media_type": "image"
},
{
"id": 17,
"story_id": "10",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/15822041034561582204080147.png",
"media_type": "image"
},
{
"id": 18,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15822043607881582204337986.png",
"media_type": "image"
},
{
"id": 19,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15822046103871582204588270.png",
"media_type": "image"
},
{
"id": 20,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/15822618660141582261864872.png",
"media_type": "image"
},
{
"id": 21,
"story_id": "10",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/1582634405989viip-1582634407396.jpg",
"media_type": "image"
},
{
"id": 22,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582636891332viip-1582636892921.jpg",
"media_type": "image"
},
{
"id": 23,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582637160907viip-1582637162291.jpg",
"media_type": "image"
},
{
"id": 24,
"story_id": "10",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/1582690826825viip-1582690804023.jpg",
"media_type": "image"
},
{
"id": 25,
"story_id": "10",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/1582694429329viip-1582694406698.jpg",
"media_type": "image"
},
{
"id": 26,
"story_id": "10",
"file": "https://viip.s3.amazonaws.com/public/img/StoryMedia/1582700721729viip-1582700707049.jpg",
"media_type": "image"
},
{
"id": 27,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582701163640viip-1582701130139.jpg",
"media_type": "image"
},
{
"id": 28,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582701307953viip-1582701279663.jpg",
"media_type": "image"
},
{
"id": 29,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582702141637viip-1582702114303.jpg",
"media_type": "image"
},
{
"id": 30,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582702412389viip-1582702387226.png",
"media_type": "image"
},
{
"id": 31,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582702745926viip-1582702743875.mp4",
"media_type": "video"
},
{
"id": 32,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582707847739viip-1582707842479.png",
"media_type": "image"
},
{
"id": 33,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582716144797viip-1582716136297.png",
"media_type": "image"
},
{
"id": 34,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582720821843viip-1582720802758.png",
"media_type": "image"
},
{
"id": 35,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582721054939viip-1582721032773.png",
"media_type": "image"
},
{
"id": 36,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582722013827viip-1582722009558.png",
"media_type": "image"
},
{
"id": 37,
"story_id": "10",
"file": "https://viip.s3.us-east-2.amazonaws.com/public/img/StoryMedia/1582722053554viip-1582722040403.mp4",
"media_type": "video"
}
],
"user_story_data": {
"name": "test"
}
}
]
}
}
This is my json how to use in this library and please explain how to implement in model because it have 4 model class and i am confuse to implement in like - IGStories ,IGSnap,IGUser and IGStory.
from instagram_stories.
from instagram_stories.
Hi @promaticsArun
We hope you have resolved this query. Due to this, we closing it for now. if anything comes up later, please reach us.
from instagram_stories.
Related Issues (20)
- cannot find 'IGAppUtility' in scope HOT 2
- There is issue with memory. it no releasing memory while we dismiss viewController HOT 2
- Pause story when app goes to background and resume in foreground mode HOT 2
- Not Support other langugae .In arebic language its not working HOT 1
- While playing video if it stops due to network issue, How I can resume progress bar again? HOT 2
- swiftUI 2.0 solution? HOT 3
- Need swipe left or right inside one story cell i.e over scrollview HOT 1
- How do I integrate the stories collection as a part of my viewcontroller (with storyboard) file? HOT 4
- Story with 100 snaps
- Remove Snaps From Story || Crash when user back after story delete HOT 3
- view controller turns into full screen HOT 1
- ipad issue HOT 2
- Adding that module causes disturbance in remaining app layout
- I'm not able to play video Mainfest file. HOT 4
- How to configure Source folder HOT 5
- Download Story HOT 1
- Swipe up on storyview and it dismissed automatically HOT 1
- didCompletePreview method not being called in my controller, as i want to make the seen request to server HOT 6
- How to save story id when every story start HOT 2
- not work on ipad HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instagram_stories.