Layer + Parse iOS Example (Swift)

Overview

Build Status Atlas+Parse Header

Note: I no longer actively working on this project. If you encounter any problem, please open an issue and hopefully the community will help out. If you are interested to maintain this project, kindly contact me. :-)

Layer + Parse iOS Example (Swift)

This repository contains an example project that demonstrates how to implement an iOS chat application in Swift with messaging services provided by Layer, user interface components from Atlas and a user backend provided by Parse.

Here is the original project in Objective-C from Layer: Layer-Parse-iOS-Example

Atlas+Parse Image

Requirements

This application requires Xcode 7 and the iOS SDK v9.0. Dependencies are managed via CocoaPods to simplify installation.

Please use the Cocoapods version 0.39 or above.

Setup

  1. Clone the project from Github: $ git clone https://github.com/kwkhaw/Layer-Parse-iOS-Swift-Example.git
  2. Install the dependencies in the root directory via CocoaPods: $ pod install
  3. Open Layer-Parse-iOS-Swift-Example.xcworkspace in Xcode.
  4. Replace LayerAppIDString , ParseAppIDString , and ParseClientKeyString in AppDelegate.swift with your Layer and Parse credentials.
  5. Add the Layer Parse Module to your Parse Cloud Code to serve as an authentication manager.
  6. (Recommended) If you want test users, import the Resources/Users.json file into your User class on Parse.
  7. Build and run the application on your Simulator to create a new user and begin messaging!
  8. Please follow this guide to configure the push notification on iOS Dev Center.

For more in-depth documentation about this project, check our guide.

Atlas+Parse Gif

Highlights

  • Uses ParseUI to authenticate and create new users.
  • Demonstrates how to get identity tokens from Parse Cloud Code using the Layer Parse Cloud Module
  • Uses Atlas, Layer's UI components

Configuration

In order to populate the sample app with content, you must configure the following variable inside AppDelegate.swift:

  • LayerAppIDString: The Layer application identifier for your application.
  • ParseAppIDString: Your Parse App ID.
  • ParseClientKeyString: Your Parse Client Key.

Credits (original project Layer-Parse-iOS-Example)

This project was lovingly crafted in San Francisco. At Layer, we are building the full-stack building block for communications. We value, support, and create works of Open Source engineering excellence.

License

Layer-Parse-iOS-Swift-Example is available under the Apache 2 License. See the LICENSE file for more info.

Comments
  • Swift 2.1 : Command failed due to signal: Segmentation fault: 11

    Swift 2.1 : Command failed due to signal: Segmentation fault: 11

    I just updated Xcode to 7.1 which includes update to Swift 2.1 after which i am getting a segmentation fault error when building the project.

    After digging around i was able to figure out that this was because of a type cast issue in ConversationViewController.swift

    I have tried everything but nothing seems to work. Could you please help me out on this?

    Here is the code below

    let status: LYRRecipientStatus! = LYRRecipientStatus(rawValue: Int(recipientStatusDict[participantAsString]!.unsignedIntegerValue))  
    
    opened by sysadminPSQ 5
  • Image Upload & Location Issue!

    Image Upload & Location Issue!

    Hi @kwkhaw ,

    There is a UI problem when you have the keyboard open and you choose to upload an image, the keyboard overlaps the action view. I think this is an Atlas issue. Should I report the issue on the Atlas-iOS page? Also the location button doesn't send the location. screen shot 2015-10-04 at 3 20 12 pm

    Thank You!

    opened by dcflow 5
  • Error Preventing Compiling

    Error Preventing Compiling

    When I go to build in Xcode, I get an error around line 63 of the conversationViewController, pertaining to the NSAttributedString for the date (Screenshot below).

    Any ideas? screen shot 2015-07-20 at 1 27 31 am

    opened by sitver 5
  • Participant Issue!

    Participant Issue!

    If I select a conversation before the chat name has been updated then return user! line 58 in ConversationViewController throws an error because it's nil. Maybe because queryAndCacheUsersWithIDs is done on the background and it hasn't finished yet.

    opened by dcflow 5
  • Upload Parse Cloud Code

    Upload Parse Cloud Code

    Hi,

    Can you please upload the Parse Cloud code used to generate the token? Having a hard time figuring out how to create the JOSE Header and JWT Claims Set.

    Thanks!

    opened by bopeola21 3
  • Fixed build errors and optional handling

    Fixed build errors and optional handling

    Overall, my changes minimised the implicit unwrapping of optional values, which may cause a runtime crash, when there's a possibility that the variable is nil.

    These issues are indirectly shown by the latest Swift compiler build errors

    opened by jessearmand 3
  • App crash

    App crash

    After creating a group conversation, I added my simulator as a participant from my actual phone, the app on the simulated crashes while starting. The error is

    fatal error: unexpectedly found nil while unwrapping an Optional value

    It is caused by the line

    func conversationListViewController(conversationListViewController: ATLConversationListViewController!, avatarItemForConversation conversation: LYRConversation!) -> ATLAvatarItem! {
        let userID: String = conversation.lastMessage.sender.userID // <- this line throws nil pointer error
        if userID == PFUser.currentUser()!.objectId {
            return PFUser.currentUser()
        }
        let user: PFUser? = UserManager.sharedManager.cachedUserForUserID(userID)
        if user == nil {
            UserManager.sharedManager.queryAndCacheUsersWithIDs([userID], completion: { (participants, error) in
                if participants != nil && error == nil {
                    self.reloadCellForConversation(conversation)
                } else {
                    print("Error querying for users: \(error)")
                }
            })
        }
        return user;
    }
    

    There are 2 message in the conversation but this method call for 4 times, at the 4. step conversation.lastMessage is nil

    opened by isacikgoz 3
  • Auto Layout constraint issue

    Auto Layout constraint issue

    I got a bug when I tested the "Layer-Parse-ios-Swift-Example". I am using xcode 7 and swift 2.

    When I enter into the "ConversationViewController", it shows UI Auto Layout constraint issue as following:


    2015-09-27 12:47:17.669 ****[4979:2415335] Unable to simultaneously satisfy constraints.

    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSLayoutConstraint:0x150dc7760 H:|-(8)-UILabel:0x150d65700 (Names: '|':UIView:0x150a31f00 )>", "<NSLayoutConstraint:0x150d52880 UILabel:0x150d65700.right == UIView:0x150a31f00.right - 8>", "<NSLayoutConstraint:0x150e5a0b0 UIView:0x150a31f00.width == ATLConversationView:0x14f750d70.width>", "<NSLayoutConstraint:0x150d4d480 'UIView-Encapsulated-Layout-Width' H:[ATLConversationView:0x14f750d70(0)]>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x150d52880 UILabel:0x150d65700.right == UIView:0x150a31f00.right - 8> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.


    Can you help have a look at this?

    opened by deeplearningcj 3
  • Error on signing up

    Error on signing up

    using this example on the swift 2 branch, the app builds, Ive set up the cloud code side, parse shows its signing up the users through the login screen when the app builds and runs on my phone but i get a constant activity spinner and the following error:

    2015-09-09 08:43:46.789 Layer-Parse-iOS-Swift-Example[48891:3291859] LayerKit client v0.15.0 loaded Failed to connect to Layer: Error Domain=com.layer.LayerKit.Errors Code=6000 "The client is already in the process of establishing a connection." UserInfo={NSLocalizedDescription=The client is already in the process of establishing a connection.} fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

            /*
            * 2. Acquire identity Token from Layer Identity Service
            */
            PFCloud.callFunctionInBackground("generateToken", withParameters: ["nonce": nonce, "userID": userID]) { (object:AnyObject?, error: NSError?) -> Void in
                if error == nil {
                    let identityToken = object as! String
                    self.layerClient.authenticateWithIdentityToken(identityToken) { authenticatedUserID, error in
                        if (!authenticatedUserID.isEmpty) {
                            if (completion != nil) {
                                completion(success: true, error: nil)
                            }
                            print("Layer Authenticated as User: \(authenticatedUserID)")
                        } else {
                            completion(success: false, error: error)
                        }
                    }
                } else {
                    print("Parse Cloud function failed to be called to generate token with error: \(error)")
                }
            }
        }
    }
    

    getting a Thread 1: Exc Breakpoint on this line of code " if(authenticatedUserID.isEmpty){

    opened by ghost 3
  • Conversation can't be selected / opened!

    Conversation can't be selected / opened!

    After i select conversation and go back to conversation list, and then close app with home button and open app again, I can't select conversation. This issue is also mentioned in the last comment here: https://github.com/kwkhaw/Layer-Parse-iOS-Swift-Example/issues/2

    opened by Deviz 3
  • Compiler Error

    Compiler Error

    Hello,

    I did the complete install and cannot get it to compile. Please view attached pic. I did the pod install and even a pod update, etc. Any thoughts? Am I missing something?

    Thanks,

    AG

    screen shot 2015-07-09 at 11 27 58 pm
    opened by agodoy21 3
  • error when implement ATLConversationViewControllerDataSource

    error when implement ATLConversationViewControllerDataSource

    this is my code :

    class test: ATLConversationViewController, ATLConversationViewControllerDataSource, ATLConversationViewControllerDelegate {
        var dateFormatter: NSDateFormatter = NSDateFormatter()
        var usersArray: NSArray!
    
        override func viewDidLoad() {
            super.viewDidLoad()
            self.dataSource = self
            self.delegate = self
            print("addressBarController: \(self.addressBarController)")
            self.addressBarController.delegate = self
    
            // Uncomment the following line if you want to show avatars in 1:1 conversations
            // self.shouldDisplayAvatarItemForOneOtherParticipant = true
    
            // Setup the dateformatter used by the dataSource.
            self.dateFormatter.dateStyle = NSDateFormatterStyle.ShortStyle
            self.dateFormatter.timeStyle = NSDateFormatterStyle.ShortStyle
    
            self.configureUI()
        }
    
        // MARK - UI Configuration methods
    
        func configureUI() {
            ATLOutgoingMessageCollectionViewCell.appearance().messageTextColor = UIColor.whiteColor()
        }
    
        // MARK - ATLConversationViewControllerDelegate methods
    
        func conversationViewController(viewController: ATLConversationViewController, didSendMessage message: LYRMessage) {
            print("Message sent!")
        }
    
        func conversationViewController(viewController: ATLConversationViewController, didFailSendingMessage message: LYRMessage, error: NSError?) {
            print("Message failed to sent with error: \(error)")
        }
    
        func conversationViewController(viewController: ATLConversationViewController, didSelectMessage message: LYRMessage) {
            print("Message selected")
        }
    
        // MARK - ATLConversationViewControllerDataSource methods
    
        func conversationViewController(conversationViewController: ATLConversationViewController, participantForIdentifier participantIdentifier: String) -> ATLParticipant? {
            let user = PFUser()
            return user
        }
    
        func conversationViewController(conversationViewController: ATLConversationViewController, attributedStringForDisplayOfDate date: NSDate) -> NSAttributedString {
            return NSAttributedString()
        }
    
        func conversationViewController(conversationViewController: ATLConversationViewController, attributedStringForDisplayOfRecipientStatus recipientStatus: [NSObject:AnyObject]) -> NSAttributedString {
            return NSAttributedString()
        }
    
    }
    

    and this is error : Type 'test' does not conform to protocol 'ATLConversationViewControllerDataSource'

    opened by KhaledAld 0
  • Name of participant is nil

    Name of participant is nil

    From here: https://github.com/layerhq/Layer-Parse-iOS-Example/issues/24

    I know you are no longer working on this project, but maybe you would have a clue to what's wrong.

    From the link: "To generate issue do following:

    1. Run app
    2. Select conversation
    3. View that the name of participant is shown in AddressBar
    4. Go back to ConversationListView
    5. Toggle the home button (while app is running)
    6. Open app
    7. Select conversation (the participant name is no longer shown)

    If you go back and tap a conversation again then name of participant is shown again."

    opened by Deviz 0
Owner
Kien
Kien
A utility used to parse number strings

NumberParser is a Swift package used to parse number strings, e.g. "eight thousa

Dalton Claybrook 4 Dec 28, 2021
Setup your class structure in Xcode Interface Builder and save() in Parse Server.

ISParseBind With ISParseBind you can save, update and query PFObjects using the power of Xcode Interface Builder resources. https://www.youtube.com/wa

Weni 10 Mar 28, 2022
A library for Search & Parse the weather data from Wunderground & Openweathermap conveniently.

SmileWeather A library for Search & Parse the weather data from Wunderground & Openweathermap conveniently. #What can it do for you? 1. Handle all com

Rain 482 Sep 28, 2022
Approov-service-ios-swift-grpc - Approov service layer for iOS clients using GRPC

Approov Service for GRPC A wrapper for the Approov SDK to enable easy integratio

Approov Integration Examples 0 Jan 21, 2022
An elegant yet powerful iOS networking layer inspired by ActiveRecord.

Written in Swift 5 AlamoRecord is a powerful yet simple framework that eliminates the often complex networking layer that exists between your networki

Tunespeak 19 Nov 19, 2022
iOS 15, MVVM, Async Await, Core Data, Abstract Network Layer, Repository & DAO design patterns, SwiftUI and Combine

iOS 15, MVVM, Async Await, Core Data, Abstract Network Layer, Repository & DAO design patterns, SwiftUI and Combine

Conrado Mateu Gisbert 18 Dec 23, 2022
Network abstraction layer written in Swift.

Moya 14.0.0 A Chinese version of this document can be found here. You're a smart developer. You probably use Alamofire to abstract away access to URLS

Moya 14.4k Jan 1, 2023
Elegant network abstraction layer in Swift.

Elegant network abstraction layer in Swift. 中文 Design Features Requirements Communication Installation Usage Base Usage - Target - Request - Download

null 100 Dec 9, 2022
A generic network layer written in swift

SwiftyNet 1.0.0 A generic network layer written in swift. you can use it as an abstraction layer above Alamofire with generic returned types. Installa

Mohamed Salah Zidane 17 Oct 11, 2021
Generic Network Layer created using Swift.

Generic-Network-Layer_iOS Generic Network Layer created using URLSession. Networking is an essential element in app development, and you'll need API c

Shubham Kr. Singh 41 Dec 31, 2022
Network abstraction layer written in Swift.

Moya 15.0.0 A Chinese version of this document can be found here. You're a smart developer. You probably use Alamofire to abstract away access to URLS

Moya 14.4k Jan 4, 2023
Alamofire Network Layer written in swift 5 using the protocol oriented, combine, UIKit, MVVM.

CoreAPI-iOS This project Contains Alamofire Network layer Based on Protocol Oriented Concept and Combine Framework. It is created with UIKit, Alamofir

Mehran Kamalifard 27 Nov 11, 2022
Type-safe networking abstraction layer that associates request type with response type.

APIKit APIKit is a type-safe networking abstraction layer that associates request type with response type. // SearchRepositoriesRequest conforms to Re

Yosuke Ishikawa 1.9k Dec 30, 2022
Dratini is a neat network abstraction layer.

Dratini Dratini is a neat network abstraction layer. If you are looking for a solution to make your network layer neat, Dratini is your choice. Dratin

Kevin Lin 37 Jan 29, 2022
Sherlock Holmes of the networking layer. :male_detective:

ResponseDetective is a non-intrusive framework for intercepting any outgoing requests and incoming responses between your app and your server for debu

Netguru 1.9k Dec 24, 2022
Lightweight network abstraction layer, written on top of Alamofire

TRON is a lightweight network abstraction layer, built on top of Alamofire. It can be used to dramatically simplify interacting with RESTful JSON web-

MLSDev 528 Dec 26, 2022
🔌 Non-blocking TCP socket layer, with event-driven server and client.

Original authors Honza Dvorsky - http://honzadvorsky.com, @czechboy0 Matthias Kreileder - @matthiaskr1 At the request of the original authors, we ask

Vapor Community 574 Dec 7, 2022
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Ronan Rodrigo Nunes 89 Dec 26, 2022
NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. ⚙️🚀

SONetworking NSURLSession network abstraction layer, using Codable and Decodable for response and Encodable for request. Project Folder and File Struc

Ahmad AlSofi 4 Jan 28, 2022