# Invoke function through device ID or particle access token \[iOS-SDK\]

**URL:** <https://community.particle.io/t/invoke-function-through-device-id-or-particle-access-token-ios-sdk/43019>\
**Category:** Troubleshooting\
**Created:** [July 15, 2018, 2:01pm UTC](https://community.particle.io/t/invoke-function-through-device-id-or-particle-access-token-ios-sdk/43019 "2018-07-15T14:01:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FA95](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@FA95](https://community.particle.io/u/FA95)\
**Post date:** [July 15, 2018, 2:01pm UTC](https://community.particle.io/t/invoke-function-through-device-id-or-particle-access-token-ios-sdk/43019/1 "2018-07-15T14:01:16Z")

</div>

In the reference guide [[https://docs.particle.io/reference/ios/](https://docs.particle.io/reference/ios/)], I can only access an account which holds the devices, which then will allow me to invoke a function. Is it possible or only invoke a function without logging in, but using the Particle Access Token or Device ID?

Thanks.

PS: I am coding using Swift not Objective-C

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [July 15, 2018, 2:14pm UTC](https://community.particle.io/t/invoke-function-through-device-id-or-particle-access-token-ios-sdk/43019/2 "2018-07-15T14:14:52Z")

</div>

I think, logging in with credentials is merely to get an accesstoken, which is then used for further communication. As such, you should be able to inject an accesstoken yourself, as is described in the reference section: “injectSessionAccessToken”. Give that a shot? (No guarantees, I’m not an iOS developer, but that’s how I do it in javascript as well.)

---

<div class="post-metadata">

**Author:** ![FA95](https://avatars.discourse-cdn.com/v4/letter/f/85f322/32.png) [@FA95](https://community.particle.io/u/FA95)\
**Post date:** [July 15, 2018, 10:26pm UTC](https://community.particle.io/t/invoke-function-through-device-id-or-particle-access-token-ios-sdk/43019/3 "2018-07-15T22:26:52Z")

</div>

You were correct! Here is is the code incase someone needs it in the near future too:

````auto
var myPhoton : ParticleDevice?
ParticleCloud.sharedInstance().getDevice("[insert device ID as string here]") { (device:ParticleDevice?, error:Error?) -> Void in
            if let _ = error {
                print("Invalid device ID")
            } else {
                print("device ID found!")
                myPhoton = device
            }
}```
````
